JS files cached, don't update new version

Hi, anyone know how come cloudflare do not know how to update JS new version files, need manually to purge the cache?

Or anyone know how to make the JS new version files be updated in cloudflare cache?

Thanks

JS files are cached by default until it expires. Or, more likely, gets evicted from the cache within a day or so.

It’s probably the same file, so… Is there a query parameter at the end of the URL?

1 Like

No, no query parameter, just update the JS files for program / function updates, why not cloudflare detect file version has been changed and update the cache automatically? Manually purge cache files is not user friendly… ? or any suggestion that can make cloudflare update automatically?

Thanks

Is this for CF Pages? The cache I believe will be purged after each deployment. The recommended thing to do though is use content hashes for the file name that way it’s always a new JS file for each release.
(I need to clarify with the team the caching behaviour)

If it isn’t for Pages, Cloudflare can’t know the file has changed without doing a fetch each time which would counteract the point of caching to reducing origin hits

Thanks,

So, how long the js cache will be expired? or keep update the file name?

The best approach would be to add a ‘ver’ query parameter when updated. But this has to be done in your site’s HTML, however that’s generated.

thanks, got it

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.