Cache Health logo: stacked pages with a lightning bolt and a green check mark
The Cache health overview page: counts of cached, partly cached and not cached pages, the settings checks with a warning about the browser and proxy cache, and a webform page that the Webform module stops from being cached
The Pages tab: every checked page with its status, its load time on the first and second visit, why it is or isn't cached, and how to fix it

This project is not covered by Drupal’s security advisory policy.

Cache Health checks whether visitors get your pages from the cache, and tells you in plain words why a page isn't cached and how to fix it.

A page that isn't cached is built again on every visit. The site gets slower and the server works harder, and Drupal gives no warning. One form that switches off the page cache, a development setting left on, or a cache time of zero is enough. Cache Health finds these problems and names the code that causes them.

Features

  • Settings checks: Internal Page Cache and Dynamic Page Cache are installed, the browser and proxy cache time isn't set to no caching, CSS and JavaScript are aggregated, and no development settings are left on (Twig debug, disabled render cache, cacheability debug headers, null cache bins).
  • A real page check: loads the front page, the main menu, and the newest page of each content type and vocabulary twice, as an anonymous visitor. A cached page is much faster the second time.
  • The reason, down to the line of code: when a page isn't cached, you see which module or theme switched off the page cache, in which function and file. You also see messages shown to every visitor, sessions started for anonymous visitors, and parts of a page that stop Dynamic Page Cache.
  • A fix for every problem, in plain words, and a count of how many pages share the same cause.
  • A Page caching line on the Status report.
  • A cache_health.check service tag, so other modules can add their own checks.

How it works

Cache Health decorates core's page cache kill switch to note which code switched it off. Then it passes the call on unchanged. During a page check, each request carries a secret key, and only those requests store notes for the report. Nothing is added to any response, so nothing can end up in a cached page, and normal visits are left alone.

Requests go only to your own site. Nothing is sent to any other service.

Requirements

  • Drupal 11.3 or later, or Drupal 12.
  • PHP 8.3 or later.
  • The server must be able to load the site's own pages over HTTP. If it can't reach the public address, you can set another one, such as http://localhost.

Getting started

  1. Install the module: composer require drupal/cache_health.
  2. Give the Administer cache health permission to the roles that look after the site.
  3. Go to Reports » Cache health and click Check pages.

Similar projects

Cache Health is for site builders. It checks your real pages and settings and explains what to change, with no developer tools needed.

Project information

  • Project categories: Performance
  • Created by alaa abbad on , updated
  • shield alertThis project is not covered by the security advisory policy.
    Use at your own risk! It may have publicly disclosed vulnerabilities.

Releases