Warming up / preloading caches 2

I have exactly the same problem as described in Warming up / preloading caches

Could this solution help?

  1. I will have 5 origin servers, one for each continent.
  2. Is there any way how to use Workers and Geolocation to warm up the cache from the nearest origin server?

I do not understand the note:

The CF-IPCountry header is not visible to visitors in the site’s HTTP response

Does this mean that geo info is not available on either the client or the worker?

Another questions:

  1. At how many places in the world is Worker KV replicated? Only on one (and where) or on more?
  2. I read somewhere that the edge cache works well if there are several requests per minute.
    Does this mean that after 60 seconds the asset can be removed from the cache?

As far as “Is there any way how to use Workers and Geolocation”:

To get country code in worker code, use e.g.

addEventListener(‘fetch’, (event) => event.respondWith(new Response(event.request.cf.country)));

That would require a Cloudflare Load Balancer setup.

That shows up in the request header that the server sees. Not the response header that the visitor sees.

KV is replicated where needed. My take is it’s more like a longer-term cache. If it’s never used at a node, it won’t be stored there. Cloudflare doesn’t divulge specifics on where KV data is stored at any particular moment.

Are you talking about KV, or regular cache? For regular cache, certainly a frequently used resource will stay in cache until Edge TTL expires. Beyond that, the algorithms are more vague. This is that “Your mileage may vary” situation.

Thanks for the explanation.

I apologize for the poorly formulated question At how many places in the world is Worker KV replicated?.

I would like to use Worker KV as a replacement for the origin server for my static readonly data. I like the concept of Bunny edge storage, which is located at five strategic places in the world (Europe, Asia, Oceania, US West, US East). They promise 41ms world wide latency. Storage is used to fill the edge cache.

Where are Worker KV data located? At one point in the US Central? Then using them to fill the edge cache in Australia can take 300-500ms.This time is mentioned by @XENOVATION in article referenced above.

Or do I misunderstand something about Worker KV completely?

According to this blog post, US and Europe are the central storage locations, and ‘cold’ data will be stored there.

1 Like

Very nice article, thanks.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.