I'm running D7 on a php-fpm/nginx stack.

I want to test out some different combinations of cache lifetime and crawler frequency and see how it affects my page cache hit rate. What is the easiest (and reasonably performant) way to create a log with time | url | ip | hit/miss for the built-in page cache.

1 Answer 1


I figured out how to make nginx do the logging in a rudimentary way. I just added the following after my fastcgi_pass directive.

log_format cache '$time_local $remote_addr $request_uri $sent_http_x_drupal_cache';
access_log /var/log/nginx/cache.log cache;

I'm not going to mark this as answered, because there are some problems with this solution:

  1. Doesn't exclude pages that don't have the X-Drupal-Cache header set (logged-in users)
  2. Doesn't exclude IPs I don't want logged (mine, for example)

For now I'll just deal with those issues when I parse the log file to create my stats, but if someone has a way to exclude them from the log then that would be preferable.

Not the answer you're looking for? Browse other questions tagged or ask your own question.