workers-sdk
workers-sdk copied to clipboard
[Miniflare] Add `Miniflare#purgeCache()` method to reset cache when required
Currently the cache is not reset when reloading the worker.
I have a [site] which gets cached, when I reload the worker to refresh the frontend ([site]), my old assets are still cached and won't get delivered until I restart MF or clear the cache some other way.
I think there should be an (optional) flag to allow resetting the cache on reload automatically.
Hey! 👋 Miniflare sets the __STATIC_CONTENT_MANIFEST for Workers Sites to {} which tricks cloudflare/kv-asset-handler into disabling caching.
Are you using Rust? Could you disable caching in development builds perhaps? In JavaScript, you could do this by checking if the globalThis.MINIFLARE variable was set:
if (globalThis.MINIFLARE) {
// ...
}
Disabling caching works fine, through the commandline arg, but I would still like to develop and test the app with the cache enabled, but this is problematic when a reload does not reset the cache.
I am not using the kv-asset-handler, but I think this feature would also be useful with the kv handler.
Hey! 👋 Thanks for raising this issue. I'm going to transfer this to workers-sdk as that's the new home for Miniflare 3, and that will make it easier for us to track this. Rather than adding this as a CLI option, it's likely we'll add this as a method to the API. This could be used to implement this behaviour programatically. 👍
Relates to #4553
any updates on this?