Expand my Community achievements bar.

AEM As Cloud | SVG images in the clientlibs resources are not picking the cache rules.

Avatar

Community Advisor

Hi Team

 

I'm hoping someone can help clarify an issue I'm facing with caching SVG assets in ClientLibs. I have implemented rules in the dispatcher (similar to the ones below) that should ideally set a max-age for assets within the ClientLibs loaded via etc.clientlibs. However, when I run a Lighthouse report, I'm not seeing any of the SVG assets in the resources folder being cached properly.

 

<LocationMatch "^/etc\.clientlibs/.*\.(?i:json|png|gif|jpe?g|svg)$">
Header set Cache-Control "max-age=15780000,s-maxage=86400,stale-while-revalidate=43200,stale-if-error=43200,public"
Header set Age 0
</LocationMatch>

I've verified that:

  • The similar rules on other assets in the content/dam folder. 
  • The SVG assets are located within the resources folder of the ClientLib.

I am not sure if it is not applying only for SVG from etc.clientlibs. or other assets like JPEG or PNG as I do not have such files in resources as of now. I cannot deploy them as this issue is observed in the client server. 

 

AEM version: AEM As Cloud

 

TIA

Veena✌

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

6 Replies

Avatar

Level 10

@VeenaVikraman There should be any issue with default.any file as by default we allow all files to get cache.. Please check your cache rules files if it is not having any space or typo. Also, please check logs 

Avatar

Community Advisor

@Imran__Khan The rule in my OP is the exact rule , we have in the dispatcher. Do you see any issue with this rule ? I checked for typos. Doesn't seem to have any space. 

Avatar

Level 4

@VeenaVikraman  you can try to add a path independent rule like -

 

<LocationMatch "\.(jpg|jpeg|png|gif|svg|bmp)$">
Header set Cache-Control "max-age=2592000, s-maxage=31536000, stale-while-revalidate=30, stale-if-error=60, public"
</LocationMatch>

Avatar

Administrator

@VeenaVikraman 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