#Worker response is not cached by default?

6 messages · Page 1 of 1 (latest)

hardy solstice
#

I have setup workers so that it gets an image from R2 and respond with it. I tried setting Cache-Control: max-age=86400. Response had it, but didn't contain any Cf-Cache-Status. Browser doesn't try to cache it either. Other similar APIs properly caches it with over 10x faster server response time. Do I have to explicitly manage cache in worker code?

btw what is a proper way to set cache headers? using itty-router

tame fossil
#

You have to manage cache in workers yourself if the data is coming from R2. You can do that with the cache API, but I presume that you've already found that :). As for the browser not caching it, I'm not sure. Do you see the headers you set in the browser?

tiny fulcrum
hardy solstice
tiny fulcrum
#

That is correct as well, no cache on workers.dev, only custom domains. That's not why your initial issue happens though, Workers just always run in front of cache

hardy solstice