Performances between Pages, Workers, Cache, KV, Durable Objects to get the best TTFB


We want to deploy each minutes 20,000 static .html files. We want to be serverless, without Origin server, and we want to get the best TTFB for every file, even if never visited before. So, if a URL is first time visited per a search bot, a short TTFB should be positive for our SEO.

We’ve seen multiple CF services to do that, but don’t really known which one is better than another.

  • Workers Sites ( KV ) ?
    Our files should take ~60s to be deployed to all CF’s PoP of the world, but I’ve read (one year ago) there is hot and cold KV keys, consider 99% of our 20,000 files will be cold keys, I suppose this will not deliver the best TTFB.

  • Pages ?
    We don’t really known if our 20,000 files could be deployed in 60s as Workers Sites / KV, and so, if there is some kind of cold keys too.

  • Workers + Cache API ?
    Each minute call a Worker with a very big POST content of all the 20,000 files content HTML. So the Cache API is updated.
    We don’t really known the latency of reading from cache API.
    Also, we’ve read the Cache API is PoP-based, so, we surely need to send the same request to all the PoPs around the world (and if we have a solution to manually choose a PoP)

  • Workers + ESM ?
    Each minute, to bundle all the 20,000 html files inside our source code as a ES Module. So each minute we run a “wrangler publish”. Our code read the request, make a conditional require on the requested file.
    Should remove any latency, and seems to be the best option, but not sure conditional require() are possible, and don’t really known limits ( 1GB of storage, but may be a number of files limited )

  • Workers + Durable Object ?
    All content of theses 20,000 files are stored inside a Durable Object, then a Worker only return the content of the requested file.
    Currently Durable Object aren’t optimized for latency, but our idea is to used the Localisation informations of the IP to connect to the DO of his continent/country (prefix in the DO object name).
    Seems to be a good idea but we don’t known the limits of storage inside DO, and the latency if we end-user is inside the same country/continent as the DO.

Thanks for your help!

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