Does cache rules works with workers?

I've build worker based svelte app. I wanted to cache my data for 8hours (content is really changed). I set up rules cache everyhting (frist screenshot). Then in worker observability logs i see multiple request for GET / which are served within same - small amount of time (screenshot nr 2), why is that? Does cache rules works with workers ?
No description
No description
7 Replies
Chaika
Chaika5mo ago
Workers run in front of cache, you have to use the cache api in workers to use cache: https://developers.cloudflare.com/workers/runtime-apis/cache/
Cloudflare Docs
Cache
Control reading and writing from the Cloudflare global network cache.
Chaika
Chaika5mo ago
which only makes sense for some cases like if your endpoint depends on external data, if it's generated internally, probably faster to just not
interpod
interpodOP5mo ago
Ok, I see. So if for example I would like to optimize costs by cashing responses on the edge I cannot?
Chaika
Chaika5mo ago
Your worker would always run yea, even using the cache api you can't avoid the invocation
interpod
interpodOP5mo ago
I see, thanks @Chaika WAF rules like rate limiting is working properly with worker right?
Chaika
Chaika5mo ago
with workers on custom domains? yup
interpod
interpodOP5mo ago
yup thx

Did you find this page helpful?