CloudFlare not invalidating cache after max age

Hi all - I’m seeing a situation with my site where CloudFlare isn’t respecting the max-age/age for pages that are being cached. CloudFlare is returning us cached pages that are MUCH older than the max-age we set in our requests.

Some additional information - Browser Cache TTL is set to Respect Existing Headers

How long are you seeing before it’s refreshed?

Minimum Edge Cache TTL is 2 hours on Free plans, 1 hour on Pro Plans and 30 minutes on Business Plans. Not sure about Enterprise plans.

The issue is it’s not the same for all pages. Some pages are invalidating properly, where their age will tick up to 61/roll over the max-age and CloudFlare will return an EXPIRED/cache a new page. Some pages though end up not resetting their max age for quite some time. I’m unsure about how long though.

I’m on a Free plan - but Respect Existing Headers should work properly on a free plan, correct? I see as low as 30 minutes on a Free plan.

That’s Browser. Edge works differently. Maybe Support can provide a better answer. Hopefully. Let us know.

Login to Cloudflare and then contact Cloudflare Support by clicking on the Get More Help button.

yes age response header is age of proxy cache not browser cache set by max-age so different items

you could have cache control with max-age = 61 and cloudflare edge cache on free TTL could be 2x60x60 = 7200 seconds so age header could reach 7200 seconds before edge cache expiry while browser cache is at 61 and revalidated

If you want edge cache lower than plan’s min i.e. free at 2hrs, then you probably need to use a cloudflare worker based caching setup

That is my understanding. Probably best to ask CF tech support to be sure though.

2 Likes

Ah gotcha! Sorry - I was confusing Browser and Edge cache. Thanks! I think I understand now.

1 Like

According to https://support.cloudflare.com/hc/en-us/articles/200172516-Understanding-Cloudflare-s-CDN,

By default, Cloudflare respects the origin web server’s cache headers in the following manner unless overridden via an Edge Cache TTL Page Rule.

It makes no mention of free vs paid plans. Shouldn’t that mean the Edge Cache TTL should follow the max-age of 61 seconds we have set?

1 Like

The same information seems reflect in this forum post from a few years ago

This just seems at-odds with the behavior I’m seeing, which seems inconsistent. Some pages are expiring properly when their age is greater than the max age in the response, and some pages just stay cached without attempting to revalidate for hours.

see https://support.cloudflare.com/hc/en-us/articles/218411427#summary-of-page-rules-settings

image

2 Likes

This topic was automatically closed after 30 days. New replies are no longer allowed.