Cache everything plus edge cache TTL question

Hey, I have a website with not that many visitors, however, it will have fairly frequent posts (a news site)

So I would like to set edge cache to 1 hour, since i have a pro plan (so you can see the news articles on my homepage)

But it would also be cool to cache everything so it would be faster on regions not close to my server

After that 1 hour, would cloudflare automatically send a request to my origin server and update the cached content, or would it wait for the first visitor to come in after 1 hour and send the cache request then?

I am asking this because i probably wont have a visitor every hour from each location, and it would be nice to serve them the fresh newly cached content

I understand that i have to have a visitor from each location first to be cached, i am asking about the 1 hour intervals after it, like for example if ill get a visitor 12 hours later from that location, will he get the news site how it was like 1 hour, or 12 hours before his visit.

My server can handle it, its a vps with 4 dedicated cores and 16 gb memory.

Also, is my setup correct if i want to achieve what i just said, and is it possible?

Should i add more settings? Do i need Origin Cache Control?

Thank you so much for the answers!

CF would wait for the first visitor, subsequent visitors will get the cached versions within the 1 hour limit.

Cloudflare will not fetch anything on your site (except for the few “Always Online” pages) without it being requested first by a visitor. At this point, this first visitor gets the page and files, and they are cached for subsequent visitors. That happens at each of the datacenters, so a visit to CDG will only create cache at CDG.

You could set either GTMetrix or webpagetest.org to visit your site hourly from a few datacenters, check their documentation.

1 Like

So could i add always online next to it? Are there any drawbacks?

The Always Online feature won’t help you. It will crawl your website every 3 days, since you are on a Pro plan, but every time you purge everything, these pages are also purged. For details, please see item 11 here:

Also, keep in mind that the Browser Cache TTL and Edge Cache TTL override the cache control values from your origin, but only as long as they set a higher TTL. So you need to make sure your origin is not sending headers instructing either the browser or proxies to cache the HTML pages for longer than 1 hour.

1 Like

Also you mentioned that the visitors will get the cache done with the 1 hour limit, to make it easier for me to understand could i ask with an example?

The first visitor will come from new york at 1pm, ill create a new post at 4pm, then the next visitor from new york arrives at lets say 6pm, will the second visitor see my new post created at 4pm, with fast loading, from the cloudflare servers, or will he have to request my origin server since the cache has expired

(what im trying to ask is does cloudflare refresh their cache hourly or not, because if it just simply expires after an hour and my users have to connect to my origin server all the time then that means that its not worth it to use cache everything with low edge ttl and low visitors/region)

sorry for needing an example, its not my native language plus im not a programmer (i think thats obvious lol), so its easier for me to understand this way.

thank you so much for your help!

In your scenario, the second visitor will most likely see a fresh page retrieved from your origin. There’s no point in showing the 1pm cached page, even if it was still available, when the content has already changed at 4pm.

What you can do is set a higher Edge Cache TTL, and purge the cache upon publication of new stories. This actually can be done automatically if you use the Cloudflare plugin, and set the Automatic Cache Management feature within it. So if the day is a slower day, in terms of updates, the second visitor has a higher chance of getting a faster, cached page, but will be served a fresh page should the content change in between visits.

1 Like

There’s also a solution involving Workers and a plugin, you may want to have a look at that to see if it fits your needs.

1 Like

I’ve purchased a worker plan plus i’ve set it all up, should i delete my current page rules now that the worker is active so it wont mess with it?

Also, do i need to add anything else in cloudflare? Like change the Browser Cache Expiration, or use other page rules?

Also I can not install the normal cloudflare plugin, as it conflicts with WP Rocket that i paid for, however the cloudflare page cache plugin works normally.

Thank you so much for your help by the way, you are incredibly useful!

1 Like

Hi @nullfud,

Actually I’m not sure what to suggest here as far as page rules vs the workers solutions. Thought I pointed to that solution, I’m not so familiar with its workings, as I haven’t yet used it in any of my sites. Perhaps @sdayman may help you with these questions, as he’s a lot more familiar with it than I am.

As far as I know the Cloudflare Plugin is not needed for that solution to work, only its own plugin.