I'm looking to confirm my suspicions as anything but, if I enable caching for anonymous users then any cache logic I've implemented in custom modules, views and blocks is thrown out, is this correct? What I mean is, if I have a block showing some weather information that has a 5 minute cache but I turn on anonymous page caching, the cache logic of my block is never considered.

Is there a way around this?

2 Answers 2


The page cache just takes whatever is generated by the current page, stuffs it into a large string and stores it into the cache. As long as that cache entry is then valid, it is returned and no other code is invoked.

Once the page cache is expired, the page will be regenerated completely and any other element will either be loaded from a specific cache or rebuilt.

If it's important that certain information is kept up to date, all you need to do is make sure that the cache expiration time of the page cache is the same or lower as the one of the relevant block/page/whatever.

There is a concept, called ESI, that basically allows to define placeholders in a page cache string that can be replaced with separate request. However, Drupal 7 doesn't really allow that yet (Drupal 8 will hopefully improve this) but this is for things that actually are different based on the user, for example if you have a site that is the same for all users except a single block that is user-specific. Not for something like a weather block that is the same for all users and valid for 5 minutes.


Either of these modules should do the trick for you (quotes included are from their project pages):

  • Edge Side Includes integration:

    ... is a high performance caching solution for Authenticated users but can be helpful for Anonymous users as well.

    Typically, pages which are personalised for authenticated users (even minor personalisations, such as a block which says "Logged in as manarth") will prevent reverse-proxies (which can easily perform 100 times faster than Drupal) from caching the page, because messages intended for one user could then be seen by another.

  • Ajax Blocks

    ... permits to load some blocks by additional AJAX request after loading the whole cached page when the page is viewed by anonymous user. It is suitable for sites which are mostly static, and the page caching for anonymous users is a great benefit, but there are some pieces of information that have to be dynamic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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