Problem/Motivation

Core provides a "Browser and proxy cache maximum age" setting that is used to set the Cache-Control header:

Cache-Control: max-age=60, public

When using a reverse proxy like Varnish, this header applies to both the reverse proxy and the browser (unless the reverse proxy has some logic to remove the header before it reaches the browser).

Our use case is this:

  • We want a low max age for the browser (because we have no way to invalidate the browser cache)
  • We want a high max age for the reverse proxy (because we can invalidate this cache with cache tags)

This is possible with the s-maxage directive:

Cache-Control: max-age=60, public, s-maxage=31536000

When both max-age and s-maxage are present, s-maxage applies to shared cache and max-age applies to browsers.

Steps to reproduce

Set cache.page.max_age to a high value like a year. (The interface does not let you do that right now: #3086787: Do not use select list for setting "cache maximum age" option)
Every cacheable response is cached for a very long time by both the reverse proxy and browsers.

Proposed resolution

We could introduce a new "Proxy cache maximum age" setting that would be used to set the s-maxage directive.

I think we should handle these scenarios:
Both max ages are 0:
Cache-Control: must-revalidate, no-cache, private

Both max ages are set:
Cache-Control: max-age=60, public, s-maxage=31536000

Only max-age is set:
Cache-Control: max-age=60, public

Only s-maxage is set:
Cache-Control: max-age=0, must-revalidate, public, s-maxage=600

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3514639

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

prudloff created an issue. See original summary.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

steinmb’s picture

Issue tags: +Performance