35

On Drupal Performance Page, under the fieldset Cache you have two options. One is Minimum Cache Lifetime and the other is Expiration of cached pages.

enter image description here

What is the difference between these two.

  • Look closer at "external" word ;) – Mołot Aug 22 '13 at 11:16
  • 1
    I kind of know the answer. I thought of writing a little detailed answer just to validate my thinking and hoping that it might help others. – Gokul N K Aug 22 '13 at 11:20
  • For a detailed answer check drupal.stackexchange.com/questions/83315/… – Gokul N K Aug 25 '13 at 13:15
39

I have made following observations after spending a few hours. If there are any gaps or mistakes, do let me know. I will be happy to make editions.

First observer that none of the Options under the CACHING are interdependent. If they were you would have seen them under different field sets(or as dependent fields). Make a note of this observation and we will revisit that later.

enter image description here

Let us begin with the first option Cache Pages for anonymous users. enter image description here

When you check this option you are basically telling Drupal

Hey Beast listen, when an anonymous user visits my site,

  1. Store the generated HTML in the cache table
  2. So that I can display the same result to all users as my pages remain same for all anonymous users.
  3. And don't clear the page caches until I say clear all caches.

Also even when you don't enable the Cache Pages for anonymous users the page can still be cached by external cache systems. Eg : Boost

Now lets move to the next options which you would end up using generally.

Expiration of cached pages

enter image description here

  1. Note that this setting has nothing to do with the Drupal Database or cache tables.
  2. Read the description The maximum time an external cache can use an old version of a page. As Molot pointed out the keyword is external.
  3. So what this option basically does is it sets the header Cache Control to public and the max-age value in the header to the specified value(1 day in this case).
  4. This header tells the external Caching systems not to make a call to the server for this page until the max age, as they can show this page from their own cache. After the max-age the Caching system should check back with the Drupal server to see if the content has changed.

  5. If its a Varnish server, it doesn't make a call to Apache and returns the page from its cache. So assume that Varnish has cached a page and thousand different users made a request to that page. So it means that 1000 requests have been processed without hitting the Apache Server even once.

Minimum Cache Life Time enter image description here

If your site doesn't have a huge traffic or if you are not sure what this value is, it better to leave this value as none.

  1. This value applies not just for the pages. But all the cache objects.
  2. What this value tells is "Its ok to serve cache objects which are stale"
  3. In our case the value is set to 5 mins.
  4. If you have a page that lists the five latest blogs on your home page. What the above values means is that, if a new blog is created its ok for the blog not to appear on the listing for the five minutes.
  5. When this value is set, for the cache to be updated/recreated minimum this much time must have passed and a cache clearing action must be run[A cache clearing function should be run].
  • 1
    Thanks for this answer. I a bit confused though: for "Cache Pages for anonymous users", you say it means "don't clear the page caches until I say clear all caches." What does this "I say" represent? What will trigger the cache to be cleared? – s427 Apr 1 '15 at 9:32
  • 1
    @s427 please check drupal.stackexchange.com/questions/102976/… for details on what will trigger the cache to be cleared. – Gokul N K Apr 3 '15 at 5:18
  • 1
    What I found interesting is that this is true only if "Cache pages for anonymous users" is enabled. If not, changing "Expiration of cached pages" do nothing, and enabling "Minimum cache lifetime" sets headers. Only if caching for anonymous users is enabled and ONLY THEN "Expiration of cached pages" sets headers. This is a bit confusing... – Łukasz Zaroda Oct 7 '15 at 14:44
19

This article has a good rundown of the caching terminology of Drupal: http://www.phase2technology.com/blog/caching-in-drupal/

Summary of the relevant points:

Minimum cache lifetime is often misinterpreted as meaning "pages will be regenerated after this much time has passed". What it actually means is that pages will not be regenerated until at least this much time has passed and a cache clearing event has happened.

Expiration of cached pages is also sometimes misinterpreted. This value controls what is sent as a max-age value in a Cache-Control header and thus advises proxy servers how long they may serve the page without asking your Drupal install for a new copy. This does not mean that the page will be regenerated after this much time, it just means that the proxy server must check back with Drupal to see if a new version of the page exists after this much time. Drupal will only regenerate a page after a cache clearing event occurs.

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.