Install
Works with Drupal: ^10.3 || ^11Using dev releases is not recommended, except for testing.
Using Composer to manage Drupal site dependencies
Alternative installation files
Download tar.gz
26.63 KB
MD5: 8111f76087689a7378cb1645d9caca7a
SHA-1: 1c7066650006ab5beabb168466f929716dd95a93
SHA-256: 61b3e977ab5cf359acc8808f77cf6f57f60e4b234e8dbfaa6d7c0299e3b4817b
Download zip
30.13 KB
MD5: 9ed5df18b3187d9c3ef0741807fd3b7f
SHA-1: fc07f7487b672714dfb4972fd72416a0b10d713a
SHA-256: 4ef3276892ed34d389c665e40b20adea64bfe52fa424e6089eed79ae94bfeede
Release notes
First 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.
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.