Cache Rules for HTML
When it is safe, and how to purge
Cloudflare does not cache HTML by default. When your pages are the same for everyone, caching them at the edge takes most load off the origin — and turns many 5xx moments into a served-from-cache page instead.
When it is safe
Public pages without per-user content: articles, docs, product pages for anonymous visitors, error explainers like this one. Not: logged-in pages, carts, anything that varies by cookie.
How
Create a Cache Rule matching the paths, set Eligible for cache, and give it an Edge TTL. Bypass cache when a session cookie is present so logged-in users never see someone else’s page.
Purge on deploy
Purge by URL or by tag from your deploy pipeline; otherwise visitors see the old page until the TTL expires. Versioned asset URLs (`style.css?v=hash`) avoid the problem for CSS and JS entirely.
Serve stale on error
Enable Always Online or set stale-if-error so that when the origin fails, Cloudflare serves the last good copy instead of a 52x.
All guides