Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Is there any guideline about CDN cache settings for AEM Web Optimized Image Delivery?

Avatar

Level 1

I couldn't find any guideline about the Cache Control settings for Images delivery by Web Optimized Delivery on fastly CDN. There isn't much information is given in documentation about Optimized image delivery. 

Core image component Cache control setting in WKND project is for 30 days because the URL changes whenever we update the image. 

  • Could we do the same for Web Optimized images as well?
  • Does WebP image URL change based on timestamp like Core Image Component?
3 Replies

Avatar

Community Advisor

@UtkarshAg1 Yes, WebP images should also be cached as any other asset cached in CDN. Since those are mutable content , you can follow the caching strategy mentioned in below link fro mutable resources. in https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/con...

 

 

Thanks

Veena

Avatar

Level 1

Thanks for your reply. I am trying to understand if AEM Web Optimized Image Delivery also changes the URL of the image based on last modified date. Do you know?

 

Adding the following rule on Dispatcher have no affect on Cache Control header. AEM returns default max-age:600 

<LocationMatch "^/adobe/dynamicmedia/.*\.(?i:jpe?g|gif|js|mov|mp4|png|svg|txt|zip|ico|webp)$">
Header set Cache-Control "max-age=43200,stale-while-revalidate=43200,stale-if-error=43200" "expr=%{REQUEST_STATUS} < 400"
Header set Age 0
</LocationMatch>

Avatar

Level 9

Hi @UtkarshAg1 ,

When it comes to CDN cache settings for AEM Web Optimized Image Delivery, there isn't a specific guideline provided in the documentation. However, you can consider the following recommendations:

1. Cache Control Headers: Set appropriate Cache-Control headers for Web Optimized Images to control how long the CDN and client browsers should cache the images. A common practice is to set a cache duration of 30 days (`Cache-Control: max-age=2592000`) for static assets like images. This allows the images to be cached by the CDN and client browsers for a longer period, reducing the number of requests to the origin server.

2. URL Versioning: The URL for Web Optimized Images does not change based on a timestamp like the Core Image Component. The URL remains the same unless the image is modified or the cache is cleared. Therefore, you can set a longer cache duration for Web Optimized Images without worrying about the URL changing frequently.

3. Consider Image Updates: Keep in mind that if you frequently update the images and want the changes to be immediately visible, you may need to use cache-busting techniques such as appending a query parameter or a version number to the image URL. This ensures that the updated image is fetched from the origin server instead of relying on the cached version.

4. CDN Configuration: If you are using a CDN like Fastly, you can also configure additional caching rules and settings specific to your CDN provider. Consult the documentation or support resources provided by your CDN provider for more information on optimizing cache settings for images.

Remember that cache settings should be balanced between optimizing performance and ensuring that updated images are delivered correctly. It's recommended to test and monitor the behavior of the CDN cache with different cache control settings to ensure it aligns with your specific requirements and image update frequency.