Cache HTML pages

I'm trying to get CF to cache my home page, what headers do I need to make that happen? Current this is what is set:
No description
29 Replies
Erin
Erin2mo ago
I'm trying to NOT set up a manual cache rule, but still serve that page from the CDN
Chaika
Chaika2mo ago
You need a Page rule with Cache Everything or a Cache Rule with Cache Enabled to get it to cache html
Chaika
Chaika2mo ago
Cloudflare Docs
Default Cache Behavior · Cloudflare Cache (CDN) docs
Cloudflare respects the origin web server’s cache headers in the following order unless an Edge Cache TTL cache rule overrides the headers. Refer to …
Erin
Erin2mo ago
so we do need a cache rule for each url we want cached? I can't do it via headers only?
Chaika
Chaika2mo ago
you can do it for the entire hostname but yea, you need a cache or page rule cache rules are super flexible though. You can do it for the entire hostname (using hostname eq example.com, etc), for everything on your domain, for just things without extensions (path ends with /), etc
Erin
Erin2mo ago
ya trying to trigger it caching and I still can't not quite sure what I'm missing
Erin
Erin2mo ago
I have a rule
No description
Erin
Erin2mo ago
and the headers above but still nothing is cached so, I'm missing something
Chaika
Chaika2mo ago
that hostname isn't proxied/going through CF's CDN
Erin
Erin2mo ago
oh blah forgot to turn that on HAHAHAHAHA sigh sheesh (had to turn it off to get SSL set up)
Chaika
Chaika2mo ago
yea turn on proxy and give it a bit for dns cache/propagation you can just do Hostname equals static-test.zaytuna.edu to make all assets on the subdomain eligible/that cache rule to apply to all
Erin
Erin2mo ago
still nothing, shoot
Erin
Erin2mo ago
No description
Chaika
Chaika2mo ago
check the response headers for server: cloudflare and cf-cache-status dns cache can take a while
Chaika
Chaika2mo ago
if you are using your default dns resolver, it's probably provided by your ISP, and some ISPs override ttl to hours to reduce cache
Erin
Erin2mo ago
nah we use cf
Chaika
Chaika2mo ago
at min though it'd take 5 minutes (you had 300s ttl before)
Erin
Erin2mo ago
ok perfect, I have to run now, thanks for your help, much appreciated
Erin
Erin2mo ago
ok, so now why is it a redirect?
No description
Erin
Erin2mo ago
and what does this mean?
No description
Erin
Erin2mo ago
is there a header that indicates if it's served from the cache? ah it's this Cloudflare also sets BYPASS when your origin web server sends cookies in the response header. so you can't cache a page that has cookies? @Chaika
Chaika
Chaika2mo ago
Cloudflare Docs
Head Requests and Set-Cookie Headers · Cloudflare Cache (CDN) docs
In this page, we document how Cloudflare’s cache system behaves in interaction with:
Erin
Erin2mo ago
still not quite sure what I need to do?
Chaika
Chaika2mo ago
Interaction of Set-Cookie response header with Cache For non-cacheable requests, Set-Cookie is always preserved. For cacheable requests, there are three possible behaviors: Set-Cookie is returned from origin and the default cache level is used. If origin cache control is not enabled, Cloudflare removes the Set-Cookie and caches the asset. If origin cache control is enabled, Cloudflare does not cache the asset and preserves the Set-Cookie. A cache status of BYPASS is returned. Set-Cookie is returned from origin and the cache level is set to Cache Everything. In this case, Cloudflare preserves the Set-Cookie but does not cache the asset. A cache MISS will be returned every time. Set-Cookie is returned from origin, the cache level is set to Cache Everything and edge cache TTL is set. In this case, Cloudflare removes the Set-Cookie and the asset is cached.
do you want it to be cached and to ignore the cookie? Either stop serving the cookie or set a specific edge cache ttl
Erin
Erin2mo ago
a specific edge cache ttl? do you mean one of these? https://developers.cloudflare.com/cache/how-to/edge-browser-cache-ttl/create-page-rules/#cache-everything sorry for the questions but the docs are very technical and they're hard to figure out sometimes
Chaika
Chaika2mo ago
You're good, you can override it in your Cache Rule
Chaika
Chaika2mo ago
like so:
No description
Erin
Erin2mo ago
thanks a lot, we don't like the Rule idea but we don't need the cookies on these pages, and that works great
Want results from more Discord servers?
Add your server
More Posts