How to cache worker response?

I want to cache worker response, so that when the next request comes in, there will be no worker invocation.
7 Replies
Chaika
Chaika4mo ago
Workers run in front of cache, worker would still always be invocated
mattp
mattpOP4mo ago
@Chaika So, the worker will always be invocated even if I have set up a cache rule for the worker route, right?
Chaika
Chaika4mo ago
yes
mattp
mattpOP4mo ago
is there a default cache setting for my worker if i set a custom domain (my cf domain) to my worker?
Chaika
Chaika4mo ago
no, any cache behavior in your worker would have to be manually done with Cache API
Chaika
Chaika4mo ago
anything it fetches though would be using the default cache behavior: https://developers.cloudflare.com/cache/concepts/default-cache-behavior/
Cloudflare Docs
Default cache behavior | Cloudflare Cache (CDN) docs
Cloudflare respects the origin web server’s cache headers in the following order unless an Edge Cache TTL cache rule overrides the headers. Refer to the Edge TTL section for details on default TTL behavior.
mattp
mattpOP4mo ago
i see, thank you!
Want results from more Discord servers?
Add your server