Problem/Motivation
Lets assume we have 3 objects, which are nested in each other in the following way.
Object 1: 10 min
Object 2: PERMANENT
Object 1: 10 min
Object 3: PERMANENT
In words:
Object 1 is part of both Object 2 and 3 and Object 1 changes every 10 min.
So lets assume at t=0, Object 1 has content of 0, at t=600, it has content of t=600, etc.
So object 1 is cached at time t=0 to the cache with a ttl of 600.
So object 2 is cached at time t=2 to the cache with a ttl of 600 (inherited from object 1).
The request to Object 3 happens at time t=590.
Because object 1 is still cached at that time, object 3 now contains object 1 with content of '0'.
Object 3 is cached for 600 s.
So at time of e.g. t=1100 the contents of object 3 shows '0' for object 1, which is wrong as it should be t=600 from t=600-1200.
So for 2 cache hierarchies this almost doubles, but for three it is in the worst pattern a minimum of 3 times, etc.
So in other words you configure 1 hour and for some users its still not changed after 4 hours.
Proposed resolution
Akamai solves this problem in an elegant way by using an age property and effectively setting max-age to the current age.
In our above example:
The request to Object 3 happens at time t=590.
Because object 1 is still cached at that time, object 3 now contains object 1 with content of '0'.
Object 3 would be cached for 600s, but because the age of object 1 is 590 already, the max-age of object 3 is reduced to 10, which makes it correct.
Again this is about correctness and less about performance, yet.
Because it might be feasible that I want this to be 10 min, no matter what and don't care about the cache hierarchy prolonging it, I can in Akamai set a downstream-ttl that works like max-age now.
Its definitely possible to put a placeholder for something with a TTL to draw that later ...
Related reading: http://www.akamai.com/dl/technical_publications/akamai_esi_developers_gu...
Remaining tasks
- Discuss
- Patch
Comments
Comment #1
Wim LeersComment #5
Wim LeersComment #11
Leon Kessler CreditAttribution: Leon Kessler commentedI have found this to be an issue when using JSON:API and Dynamic Page Cache.
Output from an entity will be cached in
cache_jsonapi_normalizations
, and then that cache re-used later bydynamic_page_cache
, which will set a new max-age, not taking into account any time that had already expired since the original cache was created.This for me was causing broken image urls, as we are using time-sensitive signatures with S3. The only solution was to disable dynamic_page_cache.
For more info see:
https://www.drupal.org/project/flysystem_s3/issues/2772847#comment-14188928
Comment #12
apadernoDrupal 8.9.x is in security support only.