a month ago
Is there a way to programmatically bust the Railway CDN cache? If not, is it on the roadmap?
Attachments
8 Replies
a month ago
Not something we provide right now, and it is not on a roadmap.
If your goal is cache busting frontend files being served, most CDNs cache by the full string, query included. A common method I've seen is having each release attach a custom query string to the end of files. Like: app.js?v=build_hash most JS bundlers do this by default these days
So the question is: how does railway CDN cache? full query string? I would guess yes since I haven't see issues in my builds.
You can usually also use cache-control headers.
If you need to "bust" the cache just for you and your browser, you can also randomly append query strings on the end like ?q=1 or something. Ones that are meaningless to your app, but the cache will see as a different "key" to return content under, so it does a real lookup
Thanks. I want to invalidate the current cached item(s) after a new bundle is built. I have a manifest file that contains the file name. But the issue when I turn on CDN Caching, I think, both bundle and the manifest file are cached. Hence I will need the manifest cache to be invalidated for the clients to pick up the new bundle
yes, so that's where you can add the build_hash query string to the end of the url when fetching the manifest for clients. It ensures everything is cached until you update
a month ago
If you'd like to purge a single asset, you can use the HTTP PURGE method.
e.g. curl -X PURGE