Supra
Supra

Reputation: 1652

automatic javascript versioning to avoid browser cache clean

My web application uses a bunch of javascript files and I want to version them as and when different releases of my app are out. This is so that the users do not have to clean the cache everytime I publish a new js with my release.

Example for version 0.0.5 for my app I want all my js to be inside app/js/0.0.5/common/ etc

I am using maven. But have no clue how to automate this kind of versioning. I know one thing for sure, will need a replace plugin to replace all tokens in my jsps to the right version number at build time.

Upvotes: 2

Views: 959

Answers (1)

karaxuna
karaxuna

Reputation: 26930

You can force browser not to cache files that may update in future like this:

<script src="/app/js/0.0.5/common?nc=<generate unique string here>"></script>

so src will be different every time so browser will not cache this script

Upvotes: 1

Related Questions