Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

AEMaaCS : Dispatcher/CDN cache

Avatar

Level 5

Hi,

 

Could you please calrify my below doubts.

1> Where can we configure caching rules for CDN?

2> In dispatcher we have /cache section within which we have /rule section to define which all are the files to be cached and /invalidate section to define which all are files to be considered for invalidating. so my question is , what happens to the files which are part of /rule section but not part of /invalidate section.

3>In our project all most all files are allowed to cache in /rule section but in /invalidate section only .html and mode.json is present . so how will clientlibs and dam assets gets invalidated ?

4> Should we cache assets are not ? what is the standard ?

5> What are must cache files in any aem sites.  

6> Do we still use dispatcher flush agents in publihs for invalidation of cache in AEMaaCS?

7> Do we need to add cache-control to response header with max-age as well to cache files in dispatcher ? /rule section is not enough ?

 

Thanks,

1 Accepted Solution

Avatar

Correct answer by
Level 7

1> Where can we configure caching rules for CDN? - 

<LocationMatch "^/content/.*\.(html)$">
     Header set Cache-Control "max-age=200"
     Header set Surrogate-Control "max-age=3600"
     Header set Age 0
</LocationMatch>

these TTL's will be respected by Dispatcher/CDN both

 

2> In dispatcher we have /cache section within which we have /rule section to define which all are the files to be cached and /invalidate section to define which all are files to be considered for invalidating. so my question is , what happens to the files which are part of /rule section but not part of /invalidate section.

they will not cache on dispatcher

https://experienceleague.adobe.com/docs/experience-manager-dispatcher/using/configuring/dispatcher-c... 

3>In our project all most all files are allowed to cache in /rule section but in /invalidate section only .html and mode.json is present . so how will clientlibs and dam assets gets invalidated ?

it should be on TTL basis.

 

4> Should we cache assets are not ? what is the standard ?

Yes.

5> What are must cache files in any aem sites.  

Assets and try to cache whatever you can.

6> Do we still use dispatcher flush agents in publihs for invalidation of cache in AEMaaCS?

yes

7> Do we need to add cache-control to response header with max-age as well to cache files in dispatcher ? /rule section is not enough ?

max-age is optional.

View solution in original post

11 Replies

Avatar

Correct answer by
Level 7

1> Where can we configure caching rules for CDN? - 

<LocationMatch "^/content/.*\.(html)$">
     Header set Cache-Control "max-age=200"
     Header set Surrogate-Control "max-age=3600"
     Header set Age 0
</LocationMatch>

these TTL's will be respected by Dispatcher/CDN both

 

2> In dispatcher we have /cache section within which we have /rule section to define which all are the files to be cached and /invalidate section to define which all are files to be considered for invalidating. so my question is , what happens to the files which are part of /rule section but not part of /invalidate section.

they will not cache on dispatcher

https://experienceleague.adobe.com/docs/experience-manager-dispatcher/using/configuring/dispatcher-c... 

3>In our project all most all files are allowed to cache in /rule section but in /invalidate section only .html and mode.json is present . so how will clientlibs and dam assets gets invalidated ?

it should be on TTL basis.

 

4> Should we cache assets are not ? what is the standard ?

Yes.

5> What are must cache files in any aem sites.  

Assets and try to cache whatever you can.

6> Do we still use dispatcher flush agents in publihs for invalidation of cache in AEMaaCS?

yes

7> Do we need to add cache-control to response header with max-age as well to cache files in dispatcher ? /rule section is not enough ?

max-age is optional.

Avatar

Level 5

Thanks tushar for the reply.I have few questions please answer them
Please find my comments below .

1> I have gone through several documents regarding CDN cache, you are right that surrogate-control can be used for CDN cache, and another way is to add "s-maxage" to cache-control header itself. But in our project we have not added niether of them but still CDN is caching I guess for 5 min, I confirmed this because "x-cache=HIT" was present in the response header. So I think CDN respects even "max-age" of cache-control header as well. So getting confused whether we can continue to use ma-age property itself for both dispatcher and CDN or should I add s-maxage or surrogate-control header please confirm.

2> I think things will get cahced if we just have urls on /rules section , because we dont have assets and clientlibs as part of /invalidate section but /rules section. and they are getting cached.
3>you mean max-age ?

4>Our assets size is around 10-12 GB still ok to cache ?

7>So If we have max-age property defined that means irrespective of whether page is republished or not things gets invalidated and get new copy from server as soon as time mentioned in the max-age is over?

Avatar

Community Advisor

2) Those file will remain in cache directory, until cleared manually. /invalidate section is for file that needs to be automatically invalidated when content is updated.

3) Add rules for assets invalidation. Clientlibs follow versioning, so any update in JS/CSS will create new path for a clientlibs.

sachinarora_1-1659503660004.png

4) It should be fine until space of cache directory is good enough. I have seen cache of asset heavy as 3-6 GB.

 

7) Yes, if /enableTTL is enabled
https://experienceleague.adobe.com/docs/experience-manager-dispatcher/using/configuring/dispatcher-c...

sachinarora_2-1659504083606.png

 

 

 

 

 

Avatar

Level 5

thanks for the reply @Sachin_Arora_ can you try to answer my queries in below comment.

Avatar

Community Advisor

1> You can do it on CDN itself if you have access otherwise add at dispatcher

2> The file were cached but cache not invalidate when publish again, If you are using adaptive image servlet for rendering assets then you on't have to add png, jepg, jpg in invalidate section but add pdf and other doc in order to get invalidate.

3>If you are using adaptive image servlet for rendering assets then you on't have to add png, jepg, jpg in invalidate section but add pdf and other doc in order to get invalidate. Clientlibs does not invlidate thats why we use version clientlibs. You should not add clientlibs in invalidate part, it will have no effect.

4> You should cache assets as well like html.

5> All file execpt dynamic file which required to hit publisher and OOTB token.json, csrf.json

6> Do we still use dispatcher flush agents in publish for invalidation of cache in AEMaaCS? I think so yes.

7> Do we need to add cache-control to response header with max-age as well to cache files in dispatcher ? /rule section is not enough ? It depends what you want to achieve with cache-control header, please check https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control 



Arun Patidar

Avatar

Level 5

Thansk @arunpatidar  for the reply, 
In our website we are using acs commons "dispatcher max age header filter" osgi configuration as shown below :

{
"filter.pattern": [
"/content/xyz/us/en/home(.*).model.json(.*)",
"/content/xyz/us/en/home(.*).html(.*)",
"/content/xyz/us/en.model.json",
"/etc.clientlibs/xyz/(.*)",
"/content/dam/(.*)",
"/content/xyz/us/en/home(.*).sitemap.xml(.*)"
],
"max.age": "300"
}

and in vhost like below :

<IfModule mod_headers.c>
Header add X-Vhost "publish"
<LocationMatch "^/content/dam/xyz/.*\.(gif|ico|jpeg|jpg|png|webp|svg|swf|ttf|woff|woff2)$">
Header set Cache-Control "max-age=600"
Header set Age 0
</LocationMatch>
<LocationMatch "^/content/dam/xyz/.*/renditions/.*">
Header set Cache-Control "max-age=600"
Header set Age 0
</LocationMatch>
</IfModule>

 aprat from these two nothing else has been done:

So considering above configuration:

1> Does max-age cache control is respected by fastly CDN ?as we are not using either         s-maxage or surrogate-control.

2> Does max-age mentioned in OSGI configuration will be overriden for dam assets in dispatcther module's max-age ?

3> Is it a good practice to use ACS commons OSGI configuration for filter and max-age ?

4> What is the idela time we should give as TTL in CDN and dispatcher for .html/assets .

5> If we are having TTL as low as 5 min then what is the use of auto invalidation ?

6> Does CDN and dispatcher cache gets cleaned on every deployment on prod or stage ?

 

Thanks

Avatar

Community Advisor

The filter set headers from publisher and Apache from dispatcher, SO if you have at either place it will work.

Just make sure you allow those headers from dispatcher rules



Arun Patidar

Avatar

Level 5

@arunpatidar  thanks for the reply.

1> Does both dispatcher and CDN cache gets cleared on each deployment?

2> As per my unserstanding clientlib versioning means , everytime you make new release new version gets added to clientlibs and same will be called inside html files, but what happens to the old clientlibs which are cached inside dispatcher and CDN ? after new release new clientlib gets called and gets cached as old new will replace with new path in html files but what happens to old cached clientlibs , how will that gets flushed in dispatcher and CDN ?

@tusharbias  please you also give your inputs.