Dispatcher cache clear strategy for service | Adobe Higher Education
Skip to main content
Level 2
August 19, 2022
해결됨

Dispatcher cache clear strategy for service

  • August 19, 2022
  • 4 답변들
  • 1372 조회

Hi,

 

I have a service rendering at ../../test.xml and it returns some data (according to backend business logic) of the last 10 activated pages of a particular template.

 

Eg. getting details of the last 10 blog articles.

 

What is the best way to cache this service in dispatcher and clear the cache on activation of any page under a particular hierarchy/template type?

이 주제는 답변이 닫혔습니다.
최고의 답변: arunpatidar

If you are using ACS Common then add a cache flush rule

https://adobe-consulting-services.github.io/acs-aem-commons/features/dispatcher-flush-rules/index.html 

4 답변

Jagadeesh_Prakash
Community Advisor
Community Advisor
August 19, 2022

Hi @vinayhegde 

 

You can try below code in vhost file. You can set the maxage for cache and refresh the data periodically.

<LocationMatch "^/content/.*\.test\.(?i:xml|css|tiff)$">
Header set Cache-Control "max-age=120,s-maxage=0,stale-while-revalidate=43200,stale-if-error=43200" "expr=%{REQUEST_STATUS} < 400"
Header set Age 0
</LocationMatch>

 If you need to clear the cache on page publish you can also do a event handler

arunpatidar
Community Advisor
Community Advisor
August 19, 2022
Arun Patidar
HeenaMadan
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
August 19, 2022

It would be good if you know when this call gives updated data. If you get updated data every 30 days then cache it on dispatcher.

Below code cache xml calls for 12 hr. Add this code in vhost file.

<LocationMatch "^/content/.*\.test\.(?i:xml)$">
    Header set Cache-Control "max-age=120,s-maxage=0,stale-while-revalidate=43200,stale-if-error=43200" "expr=%{REQUEST_STATUS} < 400"
    Header set Age 0
</LocationMatch>

 

VinayHegde작성자
Level 2
August 22, 2022

Thanks, @heenamadan, and @jagadeesh_prakash for this solution. 
However, I feel the answer by @arunpatidar seems the best fit here.

 

For blogs and all, there will be no specific timeline for the addition of new content. I tried ACS Flush rules. It worked pretty fine, clearing cache only on particular hierarchy activation and it's so simple to implement.

 

Just clear cache as soon as new content comes with no time barrier, so I feel this solution is the best fit here.

 

@kautuk_sahni - Do you think ACS one could be accepted best solution here?