Some modules silently turn off caching on certain pages. How is the easiest way to check that this is the case and also identify problematic module?
-
With Boost cache it's simple, there is a html comment at the bottom of the page. with other caches it's a bit more interesting.– MołotSep 30, 2013 at 9:50
-
@Mołot I'm primarily interested in standard Drupal cache, but instructions to other caches are also appreciate.– user11153Sep 30, 2013 at 9:56
2 Answers
The easiest way is probably to inspect the HTTP response headers.
For example, with your browser DOM inspector tool ( e.g Chrome's "Network" tab )
Cache Miss
Here's some sample response headers from drupal.org showing a cache miss. In this case, using Varnish however core Drupal cache also sets similar headers.
Cache Hit
Here's one showing a standard Drupal cache hit:
-
But Drupal.org is behind Varnish, isn't it? I can't see X-Cache headers on my Drupal accessed directly. Or I would if the page I'm testing it with was cacheable?– MołotSep 30, 2013 at 9:53
-
-
For my Drupal 7 site I indeed see header
X-Drupal-Cache: HIT
but on my Drupal 6 site I don't see anything. It could be stripped by reverse proxy? Sep 30, 2013 at 10:02 -
@user11153 yes, D6 doesn't appear to set the X-Drupal-Cache HTTP header there. However D7 does so in
_drupal_bootstrap_page_cache
Sep 30, 2013 at 10:14 -
@DavidThomas So what check cache status in Drupal 6? Are there any alternatives? And thanks for instructions to D7. Sep 30, 2013 at 10:23
Adding cache headers to Drupal 6 default cache
Sadly, it's involving some core hacking.
In file includes/bootstrap.inc
change lines from
// If there is a cached page, display it.
if ($cache) {
drupal_page_cache_header($cache);
// If the skipping of the bootstrap hooks is not enforced, call hook_exit.
if ($cache_mode != CACHE_AGGRESSIVE) {
bootstrap_invoke_all('exit');
}
// We are done.
exit;
}
// Prepare for non-cached page workflow.
drupal_page_header();
break;
to
// If there is a cached page, display it.
if ($cache) {
header('X-Drupal-Cache: HIT');
drupal_page_cache_header($cache);
// If the skipping of the bootstrap hooks is not enforced, call hook_exit.
if ($cache_mode != CACHE_AGGRESSIVE) {
bootstrap_invoke_all('exit');
}
// We are done.
exit;
}
// Prepare for non-cached page workflow.
header('X-Drupal-Cache: MISS');
drupal_page_header();
break;
and the rest of instructions it's exactly as in David's answer.