Which Cache Method to use at when? Which one take precedence?

So there are two way to custom CDN cache behavior. There is a way to cache using fetch API (https://developers.cloudflare.com/workers/examples/cache-using-fetch/), so this subrequest would become cachable. There is also a Cache API (caches.default), and an example usage that looks like this https://developers.cloudflare.com/workers/examples/cache-api/. It is also used by some popular Cloudflare Workers framework (like hono's hono/cache https://hono.dev/docs/middleware/builtin/cache). So my question is, which one should I use at when? If I do both, i.e. set cf.cacheTtl when fetching a subrequest, where that subrequest route is actually cached by caches.default. Now what happens?
Cloudflare Docs
Using the Cache API
Use the Cache API to store responses in Cloudflare's cache.
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?