Information for: DEVELOPERS   PARTNERS   SUPPORT

Configuring Drupal cache settings for Varnish

You must configure your Drupal application to take advantage of Varnish®. To set your website’s cache options to external caching, open your Drupal application’s Performance page. The cache settings depend on your version of Drupal:

Note for Site Factory users

Changing Site Factory caching settings requires you to create a post-settings.php hook.

Cache settings in Drupal 9 or later

On the Performance page at /admin/config/development/performance, select an option from the Page cache maximum age list. This value sets the maximum time a page can stay in the Varnish cache. Selecting <no caching> sets the max-age value to 0, which means assets are never cached. A reasonable value is 6 hours to 12 hours.

Drupal 9 Cache settings

To configure Drupal 9 or later to use BigPipe rendering, see Enabling BigPipe rendering on Cloud Platform.

Cache settings in Drupal 7

On the Performance page at Configuration > Performance, set values for the following items:

Drupal 7 Cache settings

  • Cache pages for anonymous users checkbox: Select this checkbox.
  • Minimum cache lifetime list: Use this setting with caution. The
    minimum cache lifetime prevents Drupal from clearing page and block caches for a set period of time after you change the content of nodes or blocks. This setting can cause unexpected behavior when editing content or when using an external cache such as Varnish. If you are unsure, leave the minimum cache lifetime set to 0.
  • Expiration of cached pages list: This value is the maximum time a
    page can stay in the Varnish cache. By setting this value to <none>, the max-age header Drupal sends to Varnish is 0, which means the page will not be cached. A reasonable expiration setting is from 6 hours to 12 hours.

Important

For Drupal 7 and earlier versions, Acquia strongly recommends you do not compress cached pages, as compression can cause problems with both Varnish caching and New Relic application monitoring.