What's the recommended way to interact with cache from Workers?

Hi team, I’m trying to clarify the best practice for handling cache from Workers, and I’ve noticed two different approaches in the docs: 1. Set config & let Cloudflare handle it — for example, using Cache Using Fetch, where you configure and pass the request through with fetch(). 2. Interact directly with the Cache API — for example, using Cache API , where the Worker itself retrieves or stores content explicitly. I’m wondering: - In what situations is option 1 preferred over option 2, and vice versa? - Are there performance or reliability trade-offs between letting Cloudflare manage caching automatically versus manually interacting with the cache from the Worker? - Any pitfalls I should be aware of when choosing one approach? Thanks in advance for helping me understand the recommended practice here!
Cloudflare Docs
Using the Cache API
Use the Cache API to store responses in Cloudflare's cache.
3 Replies
Yuan
Yuan3mo ago
Hi, i am getting confused with caching with cloudflare woker too, could i ask how did you implement yours at the end
Abdallah Abis
Abdallah Abis3mo ago
We've tried to use cache using fetch, but it's not consistent, it works with Hono, but it returns DYNAMIC when called from a dispatcher/user-worker and BYPASS when called from a socket/durable object
Yuan
Yuan3mo ago
Thank you for sharing this

Did you find this page helpful?