Install
Works with Drupal: ^10.3 || ^11Using Composer to manage Drupal site dependencies
Alternative installation files
Download tar.gz
26.62 KB
MD5: 77a3bf2b068395f08d1e1c1585efc66d
SHA-1: 14edb8e4a0cc185ecf90a148b54cd7ae9c9045bb
SHA-256: 148121cfd5cb6dccdfe6c3e83eb3cadc0a17c91234d8526d32035cef895293f1
Download zip
30.12 KB
MD5: 41463d062aafce6c9869b2e4f350555e
SHA-1: 7e1d8b8658ae209359e57df36327b7c9c96d5feb
SHA-256: a39149e1b0e0769ef6b86213c92fc8194bc71059f4fee360a99394a45d152f91
Release notes
First working release of Cache Explain. It adds a block that inspects the current page and shows, for each caching layer, whether it served the page and why. It's meant for developers and
site builders trying to work out which cache is holding stale content, or why a page isn't cached.
Changes since 1.0.0-alpha1
- Fixed a JavaScript error (
FALSE is not defined) that stopped the panel from appearing. A coding-standards auto-fixer had uppercasedtrue,false
andnullinjs/cache_explain.js. There are no other changes.
Features
- Browser cache: reads
Cache-Control,Expires,ETagandLast-Modified, and explainsno-store,
no-cache,max-age,s-maxage,private,immutableand the rest. - CDN, Cloudflare: explains every
CF-Cache-Statusvalue (HIT, MISS, EXPIRED, STALE, UPDATING, REVALIDATED, BYPASS, DYNAMIC). It flags pages whose
Cache-Controlallows edge caching while Cloudflare isn't caching them, shows where the edge TTL comes from, and shows the CF-Ray data centre. - CDN, Akamai: sends Akamai's debug
Pragmaheaders and readsX-Cache,X-Cache-Remote,X-Check-Cacheableand the cache
keys. - Reverse proxy (Varnish or nginx):
X-Varnish,X-Cache,X-Cache-Hits,Age,Via. When the CDN served the
page from its own cache, this layer reports "Not reached" instead of guessing. - Drupal Internal Page Cache and Dynamic Page Cache:
X-Drupal-Cache,X-Drupal-Dynamic-Cache, plus cache tags, contexts and max-age when
cacheability debug headers are on. - Render cache and cache bins: these aren't visible over HTTP, so the block explains what they do and how to inspect them.
- An equivalent
curlcommand and a dump of every raw response header. - The panel renders inside a shadow root, so it looks the same under any theme and doesn't affect the theme's styles.
Requirements
- Drupal 10.3 or later, or Drupal 11. So far it has been tested on Drupal 11.4.
- The core Block module.
- The server must be able to make HTTP requests to its own public URL.
Installation
composer require 'drupal/cache_explain:^1.0@alpha' drush en cache_explain
Then place the Cache Explain block under Structure → Block layout, and restrict it to the Administrator role under Visibility → Roles. There is no
configuration page.
Known limitations
- Development and troubleshooting tool. Each render makes the site send a
HEADrequest to its own URL, roughly doubling the work for that page. Keep the
block admin-only, and remove it from production once you've finished investigating. - TLS certificates are not verified on the probe request, so it also works with self-signed certificates on development sites. Making this configurable is planned before
a stable release. - The probe carries no session cookie, so Drupal page-cache results describe what an anonymous visitor gets, not your logged-in view.
- CDNs cache per data centre. CDN results reflect the data centre nearest the server, which may differ from the one a visitor reaches.
- The probe URL is built from the incoming request, so make sure
trusted_host_patternsis set insettings.php. - Requires JavaScript.
- Only Cloudflare and Akamai are recognised as CDNs. Fastly, CloudFront and others show as "No CDN detected" for now. Patches are welcome in the issue queue.