Disabling automatic asset caching
# workers-help
m
I’m seeing some very confusing cache-api behaviour on a worker of mine. I’ve set cache-control headers on a .css asset to be max-age=0, no-cache, but the worker is still caching the request. I can see this because the age response header is a non-zero value and the cf-cache-status says HIT. Is there any way I can turn off this automatic asset caching/any info of what’s going on under the hood?
s
Workers always run before caching
I'm guessing the place you're fetching it from in your worker is instead the place the caching is occurring
m
Thank you for the response! I’ll have a look at that. The source is another CF worker which has been service bound.
s
Service bindings run in the same thread, not over http(s), so I'd be surprised if that directly was the cause
m
Sorry, my previous message is wrong. The fetch is from a static storage service so there are no existing cache headers on the .css asset.
I achieved my desired behaviour with this change: I added a cacheTtl: 0 flag to the fetch I make inside my worker. I hope that is an acceptable pattern https://developers.cloudflare.com/workers/runtime-apis/request/#requestinitcfproperties