Problem/Motivation
Debugging caching can be hard.
https://www.previousnext.com.au/blog/ensuring-drupal-8-block-cache-tags-...
...
Although http.response.debug_cacheability_headers: true
lets you see your tags and contexts, there's no easy way to see WTF is going on with max-age.
Unfortunately, just knowing what your #cache['max-age']
is doesn't tell you much until this pit of snakes is untangled:
- #2352009: [pp-3] Bubbling of elements' max-age to the page's headers and the page cache
- #2449749: Add #cache['downstream-ttl'] to force expiration after a certain time and fix #cache['max-age'] logic by adding #cache['age']
- #2835068: PageCache caching uncacheable responses (violating HTTP/1.0 spec) + D8 intentionally disabling HTTP/1.0 proxies = WTF
- #2951814: Always set X-Drupal-Cache and X-Drupal-Dynamic-Cache headers, even for responses that are not cacheable
- ...
But, at least knowing you're trying to do the right thing could help in the meanwhile. ;)
It also seems very useful to be able to compare Expires
vs. Cache-Control
vs. X-Drupal-Cache-Max-Age
in various circumstances and configurations as we try to navigate the snake pit.
Proposed resolution
If http.response.debug_cacheability_headers: true
is in your services.yml file, also set a X-Drupal-Cache-Max-Age
response header.
Remaining tasks
Write codeWrite tests- Reviews + refinements
- RTBC
- Commit
- Reach back down into the snake pit and try to make progress on making
max-age
actually work. :/
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
Probably none.