WPCOM-Legacy-Redirector icon indicating copy to clipboard operation
WPCOM-Legacy-Redirector copied to clipboard

Adding max-age to redirects

Open chrean opened this issue 7 years ago • 4 comments

301s are cached by browsers (at least Firefox and Chrome) with no expiry date. This poses a problem when we need to update redirects in some cases.

I suggest adding a header like Cache-Control: max-age= where seconds may be a fairly large number, perhaps even one day.

We may think of setting up a default behaviour and some configurable params.

chrean avatar May 08 '18 12:05 chrean

Should this only be for 301, and not 302?

On my local test system, I'm seeing:

Cache-Control: no-cache, must-revalidate, max-age=0

On a VIP test site, I'm seeing:

cache-control: max-age=300, must-revalidate

GaryJones avatar May 24 '19 10:05 GaryJones

Thought - if the redirect has only been added in the last 24 hours, make it max-age=60 or something really small.

If the redirect was added longer ago than 24 hours, make it a max-age={a day}.

These two values would be filterable.

The idea being that someone may add an incorrect redirect, and end up having to wait a day or force clear their cache before being able to confirm it has been fixed.

GaryJones avatar May 24 '19 10:05 GaryJones

You'll also have to be sure to avoid creating additional cache-control: headers as one could be set already.

These redirects also are cached by their max-age, respecting the TTL, upstream via proxies such as Nginx, Varnish, CDN's, etc.

bdtech avatar May 24 '19 20:05 bdtech

For VIP, the docs say:

Redirects with a 302 HTTP Status are cached for 1 minute, redirects with a 301 HTTP Status are cached for 30 minutes.

GaryJones avatar Oct 09 '20 08:10 GaryJones