1

I have set a page cache maximum age for anonymous users in Drupal 8, but it seems not to have any effects. Accesing the pages as an anonymous user, changes are visible immediately, and I can't see any headers about max-age on the source code.

I have installed some cache modules as Internal Dynamic Page Cache, Internal Page Cache and Supercache, but I don't think these should interfere with the cache on the client side.

Any suggestions?

  • Comments are not for extended discussion; this conversation has been moved to chat. – Clive Mar 15 '18 at 10:50
  • admin->development->performance->enable cache – user21641 Mar 15 '18 at 13:37
1

There was discussion in the chat, but there are still some things that can be answered.

The maximum age setting actually has not much to do with the built-in caching mechanisms of Drupal, as confusing as that is. It only controls the Cache-Control max-age header that is sent if the page is considered cacheable.

If you don't see a X-Drupal-Cache: HIT/MISS header in the response then that means your page is not cacheable. There are a number of things that can cause that, check if you have a session cookie (if yes, you need to figure out what's in there and who sets it), check that no module that you are using disables the page cache. For example captcha.module does that if you display a captcha as that can't be cached (not something like the built-in image captcha at least).

If you see that header then it is working. The Page cache modules actually don't care about that setting, they cache the page forever. However, any relevant change on the page automatically invalidates that page and fresh content is served. See https://www.drupal.org/docs/8/api/cache-api/cache-tags for more information on how that works.

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.