This is urgent: my site at https://busy-beavers.tigyog.app/
has unexpected traffic, and the origin servers are running red-hot because Cloudflare has decided to not cache most responses!
Here’s an example:
$ curl --head https://everyday-data-science.tigyog.app/
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0HTTP/2 200
date: Fri, 25 Nov 2022 18:18:17 GMT
content-type: text/html; charset=utf-8
content-security-policy: default-src 'self' https://tigyog.app; connect-src 'self' https://tigyog.app https://*.google-analytics.com https://accounts.google.com; script-src 'self' https://tigyog.app http://www.googletagmanager.com https://www.googletagmanager.com https://accounts.google.com https://js.stripe.com/ 'unsafe-eval' 'unsafe-inline'; style-src-elem 'self' https://tigyog.app https://accounts.google.com 'unsafe-inline'; style-src 'self' https://tigyog.app https://accounts.google.com/ https://lh3.googleusercontent.com/ 'unsafe-inline'; font-src 'self' https://tigyog.app; frame-src 'self' https://tigyog.app * data:; img-src 'self' https://tigyog.app data:; object-src 'self' https://tigyog.app data:
cache-control: public, max-age=30, s-maxage=60, stale-while-revalidate=3600
vary: Accept-Encoding
x-do-app-origin: 1e494334-e6b1-11ec-b1dc-0c42a19a82a7
x-do-orig-status: 200
cf-cache-status: DYNAMIC
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=FG3k3rTeGePI%2BkWcjQpY8cVFaaGbKoM1OXLjoRkavOPmNaDzxknC7CdmT%2FuvOgDTnKr6y0cNSn88USZtLdgIirurBfihvhSb3wilVzzvCqZT9L4fEfmVMgeiDiTENGVzgj3Zt1BDbZGrxq0454%2FsvRpTfj5s84mJgB1Z7M89"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 76fc62ce4f2a406c-LHR
Note that this clearly instructs Cloudflare to cache this page for 1 minute:
cache-control: public, max-age=30, s-maxage=60, stale-while-revalidate=3600
Nevertheless, I get cf-cache-status: DYNAMIC
indicating that Cloudflare is not caching this URL.
What gives? And how do I debug this?
For the pages at https://busy-beavers.tigyog.app/
under high traffic, I have added an explicit “cache rule” that marks those pages as “Eligible for cache”, after which Cloudflare seems to behave as expected. But this is not an acceptable general solution - Cloudflare needs to respect the cache-control
header!
How do I tell Cloudflare to always respect the cache-control header? And why isn’t it doing this by default?