We run a Drupal 7 site where 99% of the traffic comes from anonymous users. Sometimes the traffic can spike very fast, so caching the barely changing content is essential for the performance. Checking the headers of the returned pages from Drupal, however, we see that all requests have X-Drupal-Cache: MISS set, and all have no-cache set and the expiry date being 1978. This was tested as anonymous user. We use plain APC and no varnish.

We enabled APC and added and configured the drupal apc cache module. On admin/config/development/performance all checkboxes are activated and minimum cache lifetime and expiry are set to 1 hour. (We actually had to set those settings in settings.php, because the page would not save any changes made).

This is what the settings.php file contains:

$conf['cache_backends'] = array('sites/all/modules/apc/drupal_apc_cache.inc');
$conf['cache_default_class'] = 'DrupalAPCCache';

$conf['page_cache_without_database'] = true;
$conf['page_cache_invoke_hooks'] = false;

$conf['cache'] = 1;
$conf['cache_lifetime'] = 3600;
$conf['page_cache_maximum_age'] = 3600;

Although the APC statistics show that a lot of data is cached (opcode, system and user caches, so drupal seems to be able to put data into the cache), the headers suggest that all requests are misses. This is an example of the headers we see from anonymous requests:

Cache-Control:no-cache, must-revalidate, post-check=0, pre-check=0
Content-Type:text/html; charset=utf-8
Date:Thu, 14 Mar 2013 16:50:41 GMT
Expires:Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified:Thu, 14 Mar 2013 16:50:41 +0000
Link:<https://XXXXXX/node/637>; rel="shortlink",<https://XXXXXX/online-therapie>; rel="canonical"
X-Generator:Drupal 7 (http://drupal.org)

We do not know how to improve this situation, or how to kindly ask drupal to not send the no-cache headers for a clearly anonymous user.

Any help here? Can it be that the clean-urls or any other module is interfering here?

Thanks in advance, Stefan.

  • Do requests have cookies? – mpdonadio Mar 14 '13 at 17:09
  • Yes, I switched Chrome to anonymous mode and see cookies like this: Cookie:cIDp3PLG2XXXXXX; sIDp3PXXXXXX; has_js=1; __utma=18XXXXXX; __utmb=18XXXXXX; __utmc=18486758; __utmz=18XXXXXX.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none). Activating "$conf['omit_vary_cookie'] = true;" does not change anything, neither do I actually see a VARY header coming by. – Stefan Mar 14 '13 at 17:11
  • What happens if you use the regular DB cache backend instead of APC? – Alfred Armstrong Mar 14 '13 at 17:16
  • @AlfredArmstrong: Same thing. DB cache also shows this behaviour. – Stefan Mar 14 '13 at 17:23
  • 1
    Solved. The CAPTCHA addon caused this behaviour, even on pages where no CAPTCHA is used. – Stefan Apr 11 '13 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.