mzfrshk
CDCloudflare Developers
•Created by mzfrshk on 4/9/2025 in #workers-help
Caching worker responses in Tiered Caching with Fetch API, similar to Cache API.
I have tiered caching enabled, so I cannot use the Cache API to save worker response while returning. What I can use is Fetch API, is there any way to save cache with Fetch API, similar to how we do with Cache API (caches.put). Basically, what I want to do is, cache the API response with Fetch.
Flow:
1. Example API: GET /employee
2. Call with GET /employee
3. If cache is present --> return from cache with HIT
4. If absent --> Cache with fetch API for subsequent API calls.
5. All of this should happen within the worker code.
6. The API call should not go into worker execution and should return from the Edge cache.
I have tried multiple ways. Can't seem to figure out the right way.
1 replies