Dispatcher cache clear strategy for service | Community
Skip to main content
Level 2
Aug 19, 2022 11:46 AM UTC
Solved

Dispatcher cache clear strategy for service

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.
arunpatidar
arunpatidarAccepted solution
New Participant
Aug 19, 2022 12:59 PM UTC

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 

Arun Patidar

4 replies

Level 2
Aug 22, 2022 7:38 AM UTC

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?

Translate
HeenaMadan
New Participant
Aug 19, 2022 2:03 PM UTC

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>

 

Translate
arunpatidar
arunpatidarAccepted solution
New Participant
Aug 19, 2022 12:59 PM UTC
Arun Patidar
Jagadeesh_Prakash
New Participant
Aug 19, 2022 12:57 PM UTC

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

Translate