I was able to cache html using cache everything page rule. [IMPORTANT] Page Rules Deprecation, https://community.cloudflare.com/t/important-page-rules-deprecation/656021 are going away soon and I wanted to still cache html.
I checked Cache rules but couldn’t see any option similar to cache everything.
I tried sending ‘Cache-Control’: ‘public’ header with html responses but that did not help either.
How can I achieve cache everything without [IMPORTANT] Page Rules Deprecation, https://community.cloudflare.com/t/important-page-rules-deprecation/656021?
The Edge TTL setting here will make it work even if you don’t send a Cache-Control header from your server, but lets you send the header to further control the caching behavior if you want.
And I tested with Trace tool and it confirms that url of the html file is captured by this rule.
Still the html file is not cached. Previously with Cache everything rule it was cached couple of hours, but now I see requests hitting my server every minute.
Btw, it works with other static files types, like js, png etc. But not html.
@Laudian@oliver4
Yes, this is the only cache rule. And there are no other rules, I have disabled Page Rules (important: this product is deprecated, read more here https://developers.cloudflare.com/rules/reference/page-rules-migration/) as well.
Yes, I want to cache everything. It is a static website so everything could be cached. If I update anything on the website I purge Cloudflare cache.
I wouldn’t bother with the status code TTL setting. 200s are already set for 1 month above, and it’s helpful to cache 301/302 and 404 responses to keep those from hitting your server all the time.
I do this to keep order of everything and for housekeeping. I would not want to cache 404 urls in case there was an error in the first place which you didn’t know was 404 then being fixed. If not cached then it then has an opportunity to go to 200 which would then be cached properly. Same if you have a server issue and get 500 status error, if you had it set up without this it would cache the 500 error and not cache the proper content once the temp errors are fixed.
Same with redirects. Sometimes they are not in place for ever and I would want that content to be updated faster.
Fair enough. Though, I’d still set those TTLs pretty low to reduce the effect of unwanted repeated requests. Without that rule, Cloudflare does cache static resources for various response codes:
Thanks for the replies. I think what you said with incorrect 404s is a great idea @oliver4 .
I have the same setup, just instead of 1 month I have 8 hours. I checked again and I see that Cloudflare is still hitting the server every minute. However, when I inspect network I can see that Cloudflare caches html file. You can see cf-cache-status header:
The only difference compared to before is, Cloudflare used to hit my server every couple of hours and responding with cached version in between. But now my server gets a request much frequently.