Warming up / preloading caches

Hello together,

I have tried to use Cloudflare as a CDN in the hope the distributed caches will be access in between the CDN network. Which is sadly not the fact. But let me explain my issue

Lets say we have pages, which are rarely accessed (once a day per country), but they are critical to be fast delivered.
What happens now:

  • client requests the page from the other side of the world (e.g. client in Sydney and page in Germany)
  • response travels back to the client from the server
  • this is repeated multiple times until the page is fully loaded
  • this takes a while (multiple seconds)
  • now the cache in Cloudflare is updated
  • sadly no further access happens

What I tried to solve is to tell the CDN to preload critical pages, but sadly I haven’t found a solution with Cloudflare. Even Argo did not help in this case, since the routing is not really the problem it is the time of travelling over the long cables… Argo reduces some hunderd milliseconds, but not seconds of loading time.

So I am still open to find some solutions.
Any ideas around?

best wishes

1 Like

for me I cache all the content in the origin, in worst case scenario cf will only add around 100ms-200ms to the total loading time(which is pretty much nothing)

1 Like

There are several approaches, the one I have implemented, uses Workers KV with Expiration Keys and Cache API.

At first request, the fetch is cached on this datacenter and put in KV as well, but globally.

Then:

  • Same datacenter: Get Cached version
  • Different datacenter: Gets KV version and Caches it in this new Datacenter.

Note that Cache expires and KV expire as well. One phenomenon that will occur is Data can persist up to Cache TTL + KV TTL.

This offloads your server, and make responses faster.

2 Likes

is this a standard feature of Cloudflare? Or a custom solution?

Also not clear what you understand with Workers KV?
You mean a Key-value map?
Where do you put the KV globally? And how do you ensure it is available for a TTL-time?

Would be great if you could elaborate more.

1 Like

@boynet2 it is from my measurement also about 200-500ms, BUT per request. Means if you have about 50-70 of them it will kick it to a really long loading time

1 Like

You will need to use Cloudflare Workers

@adaptive
okay still not clear, but I assume you mean a key value map.
and my assumption is probably also correct, that I need to solve the issue in a custom (e.g. programming) solution. right?

Please have a look at this post by @eva2000:

2 Likes

@cbrandt thank you I have read the article. But the pagespeed tests are limited to the locations nearby the cache nodes/edges. So only a few caches are warmed up. Also only single pages get tested not the full website.

1 Like

Even if you were able to warm the cache on every POP, if you don’t have frequent visitors there then CF will just evict that since it’s an unused cache resource on a low-traffic domain.

5 Likes

You may have to take a look at dedicated CDN services for all your static resources to stay in their cache. And then take another look at a Workers solution for the HTML resources.

2 Likes

@Judge good point. Forgot about the cache evicting.
Is there a known policy then and how the cache gets evicted?
Afaik it is either a LRU or LFU based eviction. But would know more about the policy of Cloudflare. Any hints?

1 Like

@sdayman does Cloudflare support static resources? If so what service/part is to use there?

Cloudflare certainly caches static resources, but it’s a Pull CDN. And infrequently used resources get purged from the cache to make way for resources in higher demand. Here’s a list of what gets cached by default:
https://support.cloudflare.com/hc/en-us/articles/200172516-Which-file-extensions-does-Cloudflare-cache-for-static-content-

2 Likes

This is the only “official” info I could find: Cache misses daily - #5 by cs-cf, and it’s just confirmation of this.

You probably will only experience an eviction if your files are very infrequently accessed from a POP and there’s high demand for business/enterprise customers as said above.

2 Likes

Since I have not found till today a solution which fits to my needs I have implemented a own solution. Let me explain, but maybe you need to check if your goals fit to mine:

mandatory:

  1. my critical pages (mostly sales pages with low traffic) have to be in the CDN cache preloaded (KO criteria)
  2. to build a CDN independent solution, so if the very unexpectedly case occurs and I cannot work anymore with my current CDN provider, I want to be easily able to switch the new CDN provider
  3. I do not want to build and especially manage additional webservers for my target regions. For this are the CDNs invented and I am willing also to pay CDN-services for it, if it solves my issues. But I am unwilling to manage, to replicate and to ensure that data is properly synced first to my reverse-proxies and aftewards to the CDN reverse proxies. This brings too much senseless complexity into the solution (too many failure-points)

nice to have

  1. easy to use and to understand CDN interface
  2. use my own DNS master server and replicate/sync to CDN servers

I have already a working solution for multiple markets in combination with Cloudflare. It is still beta version, but I can add you to the beta test.
We have a working solution for: US, EU, Asia, Australia
On schedule for South America, Africa

If you are interested, get in touch with me. I can give you a free unrestricted trial in exchange for honest feedback/reviews to the solution.

best wishes

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