2

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.

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

THanks. if I change my version number (0.0.5 above) every time, will the browser cache the file ? /app/js/0.0.5/common.js and then /app/js/0.0.6/common.js etc.. will the browser be forced to use the latest one or will it used the cached one ?
Browser will use the latest one, because url changed in your case too

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.