Cloudflare Workers Caching (API)
cloudflare workerscacheworkersCloudflare Workers Caching (API) #
- nginx config and workers code to follow, below are some examples with different options and
cache-controlheader from the origin.
Workers Endpoints #
this is using the cache API, creating a cacheKey based on the URL, and should always result in a cache HIT:
curl -sX GET -I https://cache.clumsy.dev/ | grep -E "cf-cache-status|cache-control"
this uses fetch() with the {cf: { cacheEverything: true }} object, and should result in a HIT, even with cache-control: no-store:
curl -sX GET -I https://cache.clumsy.dev/everything | grep -E "cf-cache-status|cache-control"
this uses fetch() with a custom cacheTtl, removing a custom language=en header and removing the cache-control: no-store header from the origin's response and should also result in a HIT:
curl -sX GET -I https://cache.clumsy.dev/cookie | grep -E "cf-cache-status|cache-control|set-cookie"
- Next: turnstile
- Previous: playing around with r2