How to cache HTML with Page Rules going away

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?

This is what Cache Rules are for. Create a rule to match everything to your host like so:

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.

3 posts were merged into an existing topic: Page Rules Migration

I already created a cache rule and set a higher Edge TTL (8 hours). Plus, I set Ignore query string = on. Here is my configuration:

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.

Is that your only Cache Rule, and do you have an example URL that we could look at?

Hi @lutfi.altin ,

Do you have any other cache rules already set up?

Do you want to cache everything including html? or do you have some request/files which need to bypass cache for example dynamic content?

Ollie

@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.

@lutfi.altin I would recommend putting a single cache rule in place like the below.

This would cache your content for 1 month before updating.

If you put the rule in place and send website I can see if it is working for you.

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: