Understanding and Resolving Immediate Image Expiration in Browser Caches with Dynamics Media

Learn how images on websites sometimes disappear or fail to load despite being available. This article explores why this happens and how Content Delivery Networks (CDNs) and TTL (Time-To-Live) settings play a role.

Description description

Environment

Adobe Experience Manager

Issue/Symptoms

Immediate expiration of images in browsers when using Dynamics media.

The images served through Dynamics Media expire immediately in browsers, leading to excessive If-Modified-Since (IMS) requests to the origin servers and performance issues due to lack of effective caching.

Resolution resolution

To prevent images from expiring ahead of time, it is crucial to optimize CDN caching and TTL settings.

  1. Implement the < cache:header-update.allow> on< /cache:header-update.allow> metatag to prompt the CDN to refresh cache-directive headers in cached responses upon receiving a 304 response.

  2. Use the < cache:header-update.max-frequency> metadata tag to regulate the frequency of header updates in the CDN cache, thus preventing overwriting of the cache excessively.

  3. Ensure that ‘Expires’ headers are configured with future dates to prevent immediate expiration and optimize the utilization of browser caches.

  4. Monitor CDN and browser caching behavior to verify that images are delivered with accurate headers, effectively minimizing unnecessary traffic to origin servers.

By adjusting these settings and ensuring that expiration headers align with TTL configurations, unnecessary IMS requests to the origin server can be minimized, thereby prolonging the availability of images in the browser cache.

Cause

Dynamics Media allows you to set expiration times for specific images. Once the TTL passes for an image, an IMS request is triggered to the origin. If the origin server sends a 304 response (not-modified) to this, the image gets refreshed along with the ‘Expires’ header (if it also changes).

Previously, the CDN had a static TTL of 10 hours, and the ‘Expires’ header had no impact on CDN caching. But this behaviour was altered such that when an image expires either with the CDN TTL or the ‘Expires’ header, it gets refreshed again along with the headers. In short, we now override the CDN’s TTL if the ‘Expires’ header time is shorter than the configured TTL.

The impact of this CDN configuration change was that there are now more frequent IMS requests made to the origin servers for content with a low expiration time.

recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f