2

Trying to setup the Varnish cache with our drupal installation. Issue is that with all pages, it's sending max-age=0. I've set this in the setttings.php

$conf['cache_lifetime'] = 3600;

But whenever I try and view the setting in drupal, I get:

enter image description here

Which even when I set it to any value instead of <none>, it just stays as<none>.

Not sure what's going on!

  • Not sure what's going on here, but it's my understanding that Varnish (and any other external caching system) will use the page_cache_maximum_age value (the next selection on admin/config/development/performance) for its cache lifetime whereby Drupal will use the one mentioned in your question to manage its internal page cache. – Jimajamma Mar 6 '14 at 15:43
  • If that is the case, then it seems strange to me still that the max-age=0 is still being set on an anonymous user. This is obviously blocking varnish from caching it, and providing a huge load on the server for it. Any idea how to correct for the max-age=0 from being set? – Wyatt Johnson Mar 6 '14 at 15:56
  • when you surf over to admin/config/development/performance on your system, what are you setting the second cache parameter to, eg the one labeled Expiration of cached pages and with the description The maximum time an external cache can use an old version of a page.? Or are you on Drupal 6 and not seeing this? – Jimajamma Mar 6 '14 at 16:08
  • Settings are as follows. Minimum cache lifetime: <none>, Expiration of cached pages: 6 hours, Cache pages for anonymous users: YES, Cache blocks: YES. – Wyatt Johnson Mar 6 '14 at 16:12
  • ok, can you do access your site via curl? and if so include the output of curl -I www.example.com/node/1 or something similar in your question? because out of the box "this just works" but it is sounding like some module you have installed is doing something somewhere and perhaps it will leave some trail in the headers... – Jimajamma Mar 6 '14 at 16:19
5

The settings in settings.php will override any configurations you (try) to choose in the Drupal UI: /admin/config/development/performance .

$conf['cache_lifetime'] = 0;
$conf['page_cache_maximum_age'] = 21600;

These two settings would override whatever cache timings you set in the Drupal UI.

The maximum_age setting (for example 6 hours) will display in your headers as:

Cache-Control:public, max-age=21600

After making changes to the max-age and clearing the cache, if you do not see the changes reflected in the Response Headers it may be worth looking towards nginx for the answer.

As per Q&A: https://stackoverflow.com/questions/19002567/nginx-add-header-and-cache-control . It does provide good information about how cache headers are, or can be set in Nginx.

Your Answer

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

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