Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am currently building a Web application using a LAMP stack that relies on Java

ID: 646875 • Letter: I

Question

I am currently building a Web application using a LAMP stack that relies on Javascript on the front end. As the app grows and expands, I naturally plan to expand and change the javascript files. I'm concerned that many of our users' computers will cache the files (which I usually want) but I want to be proactive to make sure that new files are grabbed when I update.

The obvious answer seems to version the javascript files throughout the application so that edit.js become edit.0.3.6.js and can be updated whenever the file changes so a new version is downloaded.

I think that this is the most fail-proof method, but I question if there is an easy way to manage these versioning changes automatically. We use Github to version control all our files.

Explanation / Answer

Another way to version javascript, CSS and other such files (say background images), is to add a parameter on the URL that they link to - for example edit.js?ver=1.

When the version changes, you update the parameter - ver=2. This ensures that it will be re-fetched.

An added bonus is that you can easily search for ?ver= in your source code and possibly do a global replace.