I've loathed this issue too. There are 2 major cases to deal with
- Libraries changing (like dojo, prototype, etc)
- Your external files changing
The first is "easy" to change .. in that you create a /scripts/ dir and
all 3rd party libraries go into their own directory with version number.
New version - new directory (and hope the file names remain the same).
Then *hopefully* you have a common include file that you just need to
change once to point to the new directory. (Of course a global
find/replace in this case is easy)
The second is trickier. Relying on random query string is not fun since
it may cause some browsers/proxies to be less prone to caching which can
really affect performance. Especially if the the query string is
dynamic. An easier solution is to use place your scripts is a "special"
directory - then use a rewrite (or similar) rule to access them. So that
the path is dynamic (and somewhat bogus). For example:
/scripts/2011-04-11-072730/dojo.js - and in this case - you can have a
rewrite rule look for a pattern and remove it from the path and forward
to the script and let the default servlet handle things.
Then to populate "2011-04-11-072730" - you can do that one of 3 ways:
- At build time - calculate the timestamp and replace it
- At run time - use a configuration parameter in context.xml
- A combo of both - I like this one best since a build can trigger a
new name, but sometimes you may run into situations where you don't need
a build but you need it refreshed - so a server parameter tweak makes
this easy too (and if savvy enough can be done via JMX to save a restart
from occurring)
Good luck ...
-Tim
On 4/11/2011 5:47 PM, George Sexton wrote:
I'm looking for ideas on how other people are doing versioning in Javascript
files. I'm hitting issues if I change my files in an incompatible way, or I
upgrade files.
For example, if I upgrade from DOJO 1.5 to DOJO 1.6, the user's browsers are
not always refreshing the DOJO files, and things don't work.
Similarly, if I update a javascript function to take additional arguments,
then the browser using the old version throws an error.
I've spent a lot of time in the past few days telling users to click on the
refresh button of their browser and I'm pretty sick of it.
I've thought of versioning my whole "scripts" directory. IOW, if my app
version is 3.4.9, make the scripts directory scripts-3.4.9 to force the
browser to get files from the new location. This is kind of a pain for
version control reasons but otherwise it's OK.
I'm really looking for ideas on how other web developers are handling this
problem.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org