Cloudflare Static Assets Caching

Hi there, i'm deploying my Static SvelteKit app to Cloudflare Static Assets, and i'm wondering how Caching works (on the Edge side). I've got it so that static assets are cached in the browser, but it doesn't look like any of my other assets are cached at Cloudflare's edge (typically i'd see like a CF-Cache: Hit header or something). Am I able to specify that specific assets are cached at the edge? You'll notice in the image I shared here, I have the proper Cache-Control settings which should tell Cloudflare to Cache the assets, and I also have a Cache Rule set to allow Cloudflare to cache them at the edge too. Any ideas what the issue could be?
No description
5 Replies
Chaika
Chaikaβ€’3mo ago
Cf-Cache-Status is a CDN layer header. Workers Static Assets use KV and rely on KV cache, which just doesn't pass up a header like that. It's still all being cached smartly though, they do some fancy stuff with a manifest to make it so assets are cached for as long as possible, and the second you do an update, cache is instantly gone
I have the proper Cache-Control settings which should tell Cloudflare to Cache the assets, and I also have a Cache Rule set to allow Cloudflare to cache them at the edge too.
Workers always run in front of cache, so not going to be able to force the cdn layer to do its own (and it would be counterproductive)
Dmitry
DmitryOPβ€’3mo ago
Ahhh ok that makes sense. The reason I asked was because I noticed that in my dashboard it says the requests are uncached. But I guess this doesn't really matter since the static requests are free πŸ˜„ But like you said.. Cloudflare is still doing caching behind the scenes.. but just not at the CDN layer? So I wont see that Cf-Cache-Status: Hit header per say I figured I could still add the Cache-Control headers which basically would tell Cloudflare to like store the file at the CDN layer.. so like it wouldn't need to go fetch it from KV as frequently
Chaika
Chaikaβ€’3mo ago
yup, it's just KV and KV cache under the hood, which is the normal cdn cache but on a different layer: https://blog.cloudflare.com/faster-workers-kv/ (replace "your worker" with the magic Workers Static Assets worker)
The Cloudflare Blog
We made Workers KV up to 3x faster β€” here’s the data
Today, we’re announcing up to 3x faster KV hot reads, with all KV operations faster by up to 20ms. And we want to pull back the curtain and show you how we did it.
No description
Chaika
Chaikaβ€’3mo ago
Workers still always run in front of cache in the cdn layer, so it'll never get there. It would hurt more then help anyway, if you made a deployment you wouldn't instantly see the updated files, etc
Dmitry
DmitryOPβ€’3mo ago
Yep. Gotcha! Thank you for your time and guidance πŸ™‚

Did you find this page helpful?