cloudflare · Cloudflare Workers Docs
Workers Cache using fetch
Teaches how to control resource caching within Cloudflare Workers by implementing custom cache keys, setting TTLs, and overriding cache behavior based on origin response codes or file types using the fetch API.
Derived skill
Files assembled from official documentation
Viewing SKILL.md
Workers Cache using fetch
Teaches how to control resource caching within Cloudflare Workers by implementing custom cache keys, setting TTLs, and overriding cache behavior based on origin response codes or file types using the fetch API.
When To Use
Use when you need to implement custom caching logic in a Worker, such as normalizing cache keys for multiple origins or adjusting TTLs and cache levels via fetch requests.
Reference Files
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/workers-examples-cache-using-fetch-workflow-guide.md | A guide explaining how to cache resources by setting TTLs, custom cache keys, and cache headers within a fetch request in Cloudflare Workers. | Questions about a guide explaining how to cache resources by setting TTLs, custom cache keys, and cache headers within a fetch reques... |
examples/workers-examples-cache-using-fetch-cloudflare-workers-cache-using-fetch.text | A JavaScript example demonstrating how to use the Cloudflare Workers fetch API with the cf cache property to store and retrieve responses from the cache. | Exact payloads, commands, or snippets shown in A JavaScript example demonstrating how to use the Cloudflare Workers fetch API with the cf cache property to store an... |
examples/workers-examples-cache-using-fetch-cloudflare-workers-cache-using-fetch-2.text | A JavaScript example demonstrating how to use the fetch API with the cf object to control cache behavior in Cloudflare Workers. | Exact payloads, commands, or snippets shown in A JavaScript example demonstrating how to use the fetch API with the cf object to control cache behavior in Cloudflar... |
examples/workers-examples-cache-using-fetch-cloudflare-workers-hono-cache-using-f.text | A Hono application implementation demonstrating how to use the Cloudflare Workers Cache API with the fetch method. | Exact payloads, commands, or snippets shown in A Hono application implementation demonstrating how to use the Cloudflare Workers Cache API with the fetch method. |
examples/workers-examples-cache-using-fetch-cloudflare-workers-cache-using-fetch-.text | A Python implementation demonstrating how to use the Cloudflare Workers Cache API within a fetch handler. | Exact payloads, commands, or snippets shown in A Python implementation demonstrating how to use the Cloudflare Workers Cache API within a fetch handler. |
examples/workers-examples-cache-using-fetch-cloudflare-workers-cache-using-fetch--2.text | A Rust code example demonstrating how to use the Cloudflare Workers Cache API within a fetch event handler. | Exact payloads, commands, or snippets shown in A Rust code example demonstrating how to use the Cloudflare Workers Cache API within a fetch event handler. |
examples/workers-examples-cache-using-fetch-cloudflare-workers-cache-using-fetch-3.text | A JavaScript code snippet demonstrating how to use the fetch API with the cacheEverything option to force Cloudflare to cache an asset. | Exact payloads, commands, or snippets shown in A JavaScript code snippet demonstrating how to use the fetch API with the cacheEverything option to force Cloudflare... |
examples/workers-examples-cache-using-fetch-cloudflare-workers-cache-using-fetch-4.text | A JavaScript code example demonstrating how to use the cf.cacheKey property within a fetch request to interact with the Cloudflare Workers Cache API. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how to use the cf.cacheKey property within a fetch request to interact with t... |
examples/workers-examples-cache-using-fetch-cloudflare-workers-cache-using-fetch-5.text | A JavaScript code example demonstrating how to use the fetch API with the cf.cacheKey property to control caching behavior in Cloudflare Workers. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how to use the fetch API with the cf.cacheKey property to control caching beh... |
examples/workers-examples-cache-using-fetch-cloudflare-workers-cache-using-fetch-6.text | A JavaScript example demonstrating how to use the fetch API with the cf.cacheKey property to control caching behavior in Cloudflare Workers. | Exact payloads, commands, or snippets shown in A JavaScript example demonstrating how to use the fetch API with the cf.cacheKey property to control caching behavior... |
examples/workers-examples-cache-using-fetch-cloudflare-workers-cache-using-fetch--3.text | A Hono-based Cloudflare Worker example demonstrating how to use the Cache API to store and retrieve responses from external storage backends. | Exact payloads, commands, or snippets shown in A Hono-based Cloudflare Worker example demonstrating how to use the Cache API to store and retrieve responses from ex... |
examples/workers-examples-cache-using-fetch-cloudflare-workers-cache-ttl-by-statu.text | A JavaScript code example demonstrating how to use the cf.cacheTtlByStatus property within a fetch request to control cache duration based on HTTP response status codes. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how to use the cf.cacheTtlByStatus property within a fetch request to control... |
examples/workers-examples-cache-using-fetch-cloudflare-workers-cache-using-fetch-7.text | A JavaScript implementation demonstrating how to use the Cache API within a Cloudflare Worker to store and retrieve responses using the fetch method. | Exact payloads, commands, or snippets shown in A JavaScript implementation demonstrating how to use the Cache API within a Cloudflare Worker to store and retrieve r... |
examples/workers-examples-cache-using-fetch-cloudflare-workers-cache-using-fetch--4.text | A JavaScript example demonstrating how to use the Cache API within a Cloudflare Worker to store and retrieve responses using the fetch event. | Exact payloads, commands, or snippets shown in A JavaScript example demonstrating how to use the Cache API within a Cloudflare Worker to store and retrieve response... |
examples/workers-examples-cache-using-fetch-cloudflare-workers-cache-fetch-option.text | A text example demonstrating how to use the cache property within the fetch API options in Cloudflare Workers. | Exact payloads, commands, or snippets shown in A text example demonstrating how to use the cache property within the fetch API options in Cloudflare Workers. |
What This Skill Covers
- Determine how to cache a resource by setting TTLs, custom cache keys, and cache headers in a fetch request.
- Main sections:
Tags,Caching HTML resources,Custom cache keys,Override based on origin response code,Customize cache behavior based on request file type.
Workflow
- Open the most relevant file under
docs/for the exact documented workflow and wording. - Open
schemas/files for exact structured contracts. - Open
examples/files for concrete requests, commands, snippets, and manifests. - Do not add behavior or configuration that is not present in the attached source files.
Canonical source: https://developers.cloudflare.com/workers/examples/cache-using-fetch
