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
Chaika3d ago
Workers run in front of cache, worker would still always be invocated
mattp
mattp3d ago
@Chaika So, the worker will always be invocated even if I have set up a cache rule for the worker route, right?
Chaika
Chaika3d ago
yes
mattp
mattp3d ago
is there a default cache setting for my worker if i set a custom domain (my cf domain) to my worker?
Chaika
Chaika3d ago
no, any cache behavior in your worker would have to be manually done with Cache API
Chaika
Chaika3d 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
mattp3d ago
i see, thank you!
Want results from more Discord servers?
Add your server