Dispatcher cache clear strategy for service | Community
Skip to main content
Level 2
August 19, 2022
Solved

Dispatcher cache clear strategy for service

  • August 19, 2022
  • 4 replies
  • 1371 views

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by 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 replies

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
arunpatidarCommunity AdvisorAccepted solution
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>

 

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?