Cache everything with page rules

caching

#1

Hi! Could you please explain to me how exactly “Cache everything with page rules” works.

Let’s say i’ve set, mywebsite.com/* to:

Cache level: cache everything
Edge cache ttl: 2 weeks

Does this mean that html files also get cached for two weeks? If my website has “some text”, and I edit it today, will it take two weeks to refresh? How does this work exactly?


#2

Yes.

From the FAQ:

CAUTION: Cache-everything means all visitors will receive the cached asset therefore we do not recommend setting this on assets requiring authentication or other dynamic dependencies.

You can use Cache-Control headers to prevent pages being cached by CF.
“private”,“no-cache”, or “max-age=0”

If you know that content on some of your HTML pages will change frequently, set this headers.

If you don’t update the pages frequently, a workaround can be to purge the cache manually after
you did your changes.


#3

Yes, Cloudflare literally caches everything if that rule is applied.

So your every webpage that matches that rule will be cached for 2 weeks.

If you are running a personal blog, it is a good idea to cache everything for 1 month and if you were to post a new post, you can tell Cloudflare to specifically purge the homepage so your viewers get the updated version.


#4

If you’re using wordress I recommend the Comet Cache plugin, rather than using Cloudflare’s Cache Everything. You get a significant speed boost (up to 10x) while not having to worry about old content being cached after a textual edit.


#5

OK, great responses. So the minimal time for the cache on the free plan is 2 hours yes?


#6

That is correct!


#7

Hi!

Can i minimize this time with using; browser cache ttl - or does this setting do something different?


#8

This is only for browsers. You can set the CF cache to 4 hours and advise the browser to cache the content locally for 2 hours for example.

After this 2 hours the browser will download the content from the CloudFlare cache.


#9

Browser cache tells your visitor’s browser to cache the resources locally for x period. Once this time is up, the local cache expires and the next time the same visitor visits your site, it will request a fresh copy.

The main difference is that a user is able to clear the browser cache whereas the edge cache can only be cleared by the owner via Cloudflare interface/API.


#10

I’ve posted my settings below. And also the headers.

The problem is that the cached html does not refresh after two hours. What am I doing wrong?

Request Method:GET
Status Code:200 OK
Remote Address:104.28…
Referrer Policy:no-referrer-when-downgrade
Cache-Control:public, max-age=7200
CF-Cache-Status:HIT
CF-RAY:3ef09f3e54e097fe-FRA
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html; charset=UTF-8
Date:Sun, 18 Feb 2018 11:24:47 GMT
Expires:Sun, 18 Feb 2018 13:24:47 GMT
Pragma:no-cache
Server:cloudflare
Transfer-Encoding:chunked
Vary:Accept-Encoding
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:pl-PL,pl;q=0.9
Cache-Control:max-age=0
Connection:keep-alive


#11

I see it’s a HIT and the cache expire date is 2 hours after your visit. I think that’s the browser cache setting.

What makes you think the Edge cache isn’t refreshing? Did you make a change that’s not showing up?


#12

Yeah, I’ve changed the html and it does not refresh.

In the cache tab in CF I have a very long cache time set, wouldn’t it have to be set to respect existing settings in order for page rules to work? But that would make all my images as such only be cached for two hours.


#13

I always thought Edge Cache TTL is an independent setting and will override anything on your server. So I don’t know why your HTML isn’t refreshing. Especially considering that the headers show a 2-hour expiration.

I suggest you open a Support Ticket. Include the specific URL of the resource. It would probably also help if you included the cf-ray header from your first load, and the one 2 hours later that’s not refreshed.

Here’s the Support article on cache times:


#14

This topic was automatically closed after 14 days. New replies are no longer allowed.