Invalidate Dispatcher and CDN Cache on AEM Cloud | Community
Skip to main content
Level 2
November 24, 2023
Solved

Invalidate Dispatcher and CDN Cache on AEM Cloud

  • November 24, 2023
  • 4 replies
  • 10747 views

Did anyone come across a need to clear/invalidate Dispatcher and CDN cache completely on AEM Cloud instance. I found couple of example for single path/URL but nothing concrete on complete cache. Any help on this would be appreciated.

Note:

Changing stat level is not an option and yes we do need a complete cache clear

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 fmateen

Adobe cloud is using Fastly. Fastly provides an API to purge cache https://developer.fastly.com/reference/api/purging/

You have to develop custom code to purge cache using API. You for example can create a workflow by using which you can purge the cache by  API’s purge service or tags option.

Similarly Akamai (another CDN vendor) provides an API to purge cache by using CP code or tags but to invoke it from AEM certainly custom code is required. 
I will suggest it should be via a workflow which you can be invoked only when needed.

 

 

4 replies

MarkusBullaAdobe
Adobe Employee
Adobe Employee
November 24, 2023

Hi @omkarmanasba!

While caching is a pretty easy task, cache invalidation is a lot harder to do - at least if you are trying to do it efficiently. Active invalidation of the CDN is a tricky problem because the publish tier of AEM Cloud Services is eventually consistent. Depending on your exact requirements for caching, there might be no perfect solution at all that will be both, consistent (meaning 100% reliable) and efficient (meaning invalidating only what's necessary and no duplicate invalidations).

In addition to that, there are certain implications that you definitely do want to take into account if you are still considering active and complete invalidation of all caching layers involved for AEM CS. This will most probably have direct effect on the load and performance of the publish tier.

The overall recommendation is to leverage TTL configurations (even if set to low values of few minutes) and tailor them to the different update cycles of the resources being cached and delivered to the end user.

This leads to my disclaimer: Please handle active cache invalidation with care, be cautious about the effects it will have!

 

That being said, I have not yet seen a readily-available solution for a complete cache purge on CDN level.

You may want to explore the following community article that covers invalidation of specific paths on both, Dispatcher and CDN level for AEM CS:

You might be able to build on the outlined solution to create a "batch" invalidation of multiple paths or to explore options even beyond that.

 

Hope this helps!

Level 2
November 24, 2023

I have been though this blog already. Though this talks about invalidating single URL as such. Any header or pattern that gives a complete flush or soft purge for CDN. Any method or class which invalidates entire dispatcher cache like giving a root path or something within the SCD API

MarkusBullaAdobe
Adobe Employee
Adobe Employee
November 24, 2023

Yes this is something we would need to do at certain intervals. Not very regularly. May be once in a month.


This is definitely a red flag!

 

If your business or technical workflows do require a hard and full deletion of all cache layers on a regular basis, there is a strong need to re-evaluate and optimize these workflows. A properly designed AEM setup does not require this. It is - in the best case - a workaround for sub-optimal processes, taking care of symptoms rather than root causes.

 

Therefore I'd highly recommend to spend your efforts fixing the cause rather than developing workarounds for the symptoms you might be experiencing.

 

Please feel free to provide additional background and details on why you do think the cache clean might be necessary. What are the use cases you have in mind? What's the goal?

That way, the community might be able to guide you towards a better solution.

fmateen
Level 2
November 26, 2023

Can you please describe which CDN system you have?

Akamai for example provides an API to invalidate complete cache by using cp code.

It is also possible to implement cache tags in case you want to clear only specific file types for example html only.

 

Level 2
November 26, 2023

We currently have the OOTB CDN adobe provides with AEM cloud. On top of it. We have our own CDN. It is basically just a wrapper and forwards the request most of the time.

fmateen
fmateenAccepted solution
Level 2
November 26, 2023

Adobe cloud is using Fastly. Fastly provides an API to purge cache https://developer.fastly.com/reference/api/purging/

You have to develop custom code to purge cache using API. You for example can create a workflow by using which you can purge the cache by  API’s purge service or tags option.

Similarly Akamai (another CDN vendor) provides an API to purge cache by using CP code or tags but to invoke it from AEM certainly custom code is required. 
I will suggest it should be via a workflow which you can be invoked only when needed.

 

 

kautuk_sahni
Community Manager
Community Manager
December 4, 2023

@omkarmanasba Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni