Cloudflare support suggested I post my question here.
Like others, our site is significantly faster when requested assets are available in Cloudflare’s cache. This will always be the case, no matter how much we improve the performance of our origin server.
I can run a script when our assets/content changes, so I was hoping I could build a simple function to make the first request and prime Cloudflare’s cache.
However, I checked with Cloudflare support. Each node/colo caches independently of one another:
An asset is only cached at a specific colo when that asset is requested from that colo. There is no “cache warming” [or replicating] between colos.
So I cannot simply make one request to prime all the colos/nodes. I need some way to loop through all the colos for each asset. Some potential ideas come to mind:
-
Use webpagetest.org. They have a distributed network from which you can control where (geographically) the client requests come from. Obviously this won’t perfectly match Cloudflare’s network map, but it’s probably better than nothing. However, the most significant problem with this approach is speed. I’ve seen tests queued for 20+ minutes in some cases. Also, I don’t need to replicate a full browser environment, so this approach is likely overkill.
-
Perhaps there’s a way (request header?) to force cloudflare to respond from specific nodes/colos? This would be trivial for me to write a script to handle.
-
Another 3rd party service with a distributed network that can proxy requests from different locales. I have no idea if something like this exists (at a reasonable cost). Hoping somebody here might have ideas.
FWIW, I only really care about priming our cache in North America.