User error -- disregard :)

My issue appears to be identical to this one posted a few months ago: Cache-Control header not working. Why is Firefox revalidating everything?

I’ve configured my backblaze bucket to provide the following header:

{"cache-control":"public, s-maxage=31536000, max-age=86400"}

And when I fetch directly from BackBlaze I see these headers as expected:

Response
HTTP/1.1 200
Content-Type: image/webp
Keep-Alive: timeout=5
Date: Fri, 06 Aug 2021 21:30:29 GMT
Content-Length: 4266
Cache-Control: public, s-maxage=31536000, max-age=86400
Connection: keep-alive
Accept-Ranges: bytes
ETag: "5f45aff8c7a722ae2499854fb1d98db2"
Last-Modified: Fri, 06 Aug 2021 17:30:49 GMT
x-amz-id-2: aNdY55mN7NNsziDhRMfQ26DdwNdQ3kDjX
x-amz-version-id: 4_zf5e97cd4c3f8f13677a50718_f118f2bf198a8ee9c_d20210806_m173049_c002_v0001152_t0001
x-amz-request-id: 966866aca2cf93e3
x-amz-meta-src_last_modified_millis: 1628128073945

Now, when I first hit CloudFlare there’s a MISS. Fine.
Then, when I hit it again there’s a HIT:

< HTTP/2 200 
< date: Fri, 06 Aug 2021 23:36:59 GMT
< content-type: image/webp
< content-length: 4266
< cf-ray: 67ac172aee9ef172-PIT
< accept-ranges: bytes
< age: 10
< cache-control: public, max-age=86400, s-maxage=31536000
< etag: "5f45aff8c7a722ae2499854fb1d98db2"
< last-modified: Fri, 06 Aug 2021 17:30:49 GMT
< cf-cache-status: HIT
< expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< x-amz-id-2: aNeU5fWMLNFQzLjj7MRs2lDccNWo3ojhB
< x-amz-meta-src_last_modified_millis: 1628128073945
< x-amz-request-id: 6f70dc2335d3e997
< x-amz-version-id: 4_zf5e97cd4c3f8f13677a50718_f118f2bf198a8ee9c_d20210806_m173049_c002_v0001152_t0001
< report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=GDtvV5KHi31yOZP%2BPK4q1Ynb7BPT5pPhsEPZcIWOwJ1j23UTJtKQVgxzNSoNlFUvtXBJPbmg19HOaKR2NbN4dpxIHeqMZCV89ih1G0XcGn1UWWtujc5LxKSqtjMr9aSlyg51Lhs%2B8mY%3D"}],"group":"cf-nel","max_age":604800}
< nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
< server: cloudflare
< alt-svc: h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400, h3=":443"; ma=86400
< 

Not the 'age:10. The highest that’ll go is 59 before I get back anotehr REVALIDATED, like so:

< HTTP/2 200 
< date: Fri, 06 Aug 2021 23:38:19 GMT
< content-type: image/webp
< content-length: 4266
< cf-ray: 67ac191f0f7cf186-PIT
< accept-ranges: bytes
< cache-control: public, max-age=86400, s-maxage=31536000
< etag: "5f45aff8c7a722ae2499854fb1d98db2"
< last-modified: Fri, 06 Aug 2021 17:30:49 GMT
< cf-cache-status: REVALIDATED
< expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< x-amz-id-2: aNeU5fWMLNFQzLjj7MRs2lDccNWo3ojhB
< x-amz-meta-src_last_modified_millis: 1628128073945
< x-amz-request-id: 6f70dc2335d3e997
< x-amz-version-id: 4_zf5e97cd4c3f8f13677a50718_f118f2bf198a8ee9c_d20210806_m173049_c002_v0001152_t0001
< report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=QcpGTqO5wswDXb6rQIjZ9r0LqDLxUjWXaFUY4DfKPQMkhjG34H6933RTycMgU%2FC8w4BIgxROjbAbuDqcT6EKfxiQA7jGrkRaCfb3TJVVfkVmCk3t1rzFc5DmKdZBsCoTO%2Fd2%2BGi23%2Bc%3D"}],"group":"cf-nel","max_age":604800}
< nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
< server: cloudflare
< alt-svc: h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400, h3=":443"; ma=86400
< 

I have also configured a page rule to try and rule this to no avail – it seems to do nothing:

What am I missing?

Nothing obvious to me. But, then again, caching is black magic to me.

Do you know if the ETag is changing? Even so, I don’t know why it would feel the need to revalidate after 60 seconds.

It’s not changing; I’ve updated my initial post to include more of the request headers (HIT and REVALIDATED) in case that reveals anything?

I tell ya, it’s black magic. But my wild guess is the request is causing this:

1 Like

I just did an experiment using my own origin server instead of BackBlaze and it survives beyond 60 seconds…

I can’t seem to see any meaningful difference in the headers coming from B2 and my own nginx server which is quite strange.

You mean the headers you see through Cloudflare, or the headers from the origin? That may be the difference.

Here are the differences between the headers from BackBlaze vs my nginx server. Expires may be the culprit, but I don’t understand why it’s absence would cause CF to ignore the ‘maxage’ directive

my arbitrary nginx instance, working > 60 seconds

< expires: Sat, 07 Aug 2021 23:47:06 GMT
< cache-control: public, max-age=86400
< cf-cache-status: HIT
< age: 7

BackBlaze headers, revalidating after 60 seconds (i’ve tried it without the s-maxage as well as other combinations, too)

< cache-control: public, max-age=86400, s-maxage=31536000
< cf-cache-status: REVALIDATED
< x-amz-id-2: aNeU5fWMLNFQzLjj7MRs2lDccNWo3ojhB
< x-amz-meta-src_last_modified_millis: 1628128073945
< x-amz-request-id: 6f70dc2335d3e997
< x-amz-version-id: 4_zf5e97cd4c3f8f13677a50718_f118f2bf198a8ee9c_d20210806_m173049_c002_v0001152_t0001

@michael is really smart about stuff like this, but it’s probably pretty late where he is.

1 Like

Embarrassingly, it turns out that I had a CF Worker configured for the same domain and it was causing all this mysterious behavior! Once I resolved that everything started behaving as documented. Thank you for your assistance in helping rule things out!

What? That’s nothing. Most of us have done far worse. I’m glad you got it figured out.

But to add insult to injury, I’ve marked yours as the solution for all to see. :grin:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.