My svelte rollup.js setup has an index.html file with this head:

 <link rel='stylesheet' href='/build/bundle.css'><!-- svelte --> <link rel="stylesheet" href="/build/index.css" /><!-- tailwind --> <script defer src='/build/bundle.js'></script> 

When I deploy a new version to my web server, some clients don't fetch the new bundle.js but instead use their cached copy. What's a good way of forcing them to fetch the new bundle when I've deployed a new version?

The simplest way I can think of would be to add the version number or git commit hash to the end of src, e.g:

 <link rel='stylesheet' href='/build/bundle.css?v0.1.4'><!-- svelte --> <link rel="stylesheet" href="/build/index.css?v0.1.4" /><!-- tailwind --> <script defer src='/build/bundle.js?v0.1.4'></script> 

But I assume this is a common problem, so I'd rather ask.

1

1 Answer

There's a section in the docs about using hash's in the bundle names.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.