Backend and Infrastructure

Debug Drupal Cache Misses and Low Hit Rates for Drupal 8, 9, and 10

Drupal site performance relies heavily on caching. Optimal caching (and invalidation) requires that each page is rendered with the correct cacheable metadata. This metadata allows for intelligent caching -- but when something isn't working correctly, it can be tricky to figure out where exactly the metadata was generated from.

When debugging Drupal cache issues, you're usually trying to answer 1 of 2 primary questions:

  • Why is this cached? If the information gets stale, why isn’t it updated?
  • Why is this not cached? And why is our cache hit rate low?

The Drupal cache system consists of many layers, each of which may contribute to the problem. This tutorial focuses on debugging the Drupal application cache layer, and strategies for debugging Varnish. Given that most external to Drupal layers rely on the use of HTTP headers for caching, you should be able to use similar techniques to those used for debugging Varnish.

In this tutorial, we'll:

  • Learn strategies for debugging the Drupal application cache and render cache
  • Share strategies for debugging low hit rates when using Varnish

By the end of this tutorial, you should know how to enable and use various cache debugging mechanisms in Drupal to help identify problems in your site performance and resolve them.