mrclay/minify — Issue #10: Adding a version number to URL to force browser to re-request file
Author: lencioni
Created: 2011-11-10 18:33:22+00:00
State: open

Currently, I use a mod_rewrite rule like this:

RewriteRule ^(.*?)\.v[0-9]+\.js$ /js/$1.js [L,E=VERSIONED_FILE:1]
Header add "Expires" "Mon, 28 Jul 2014 23:30:00 GMT" env=VERSIONED_FILE
Header add "Cache-Control" "max-age=315360000" env=VERSIONED_FILE

So I can request my JavaScript file at `/js/myjavascript.js` as `/js/myjavascript.v15.js` which forces clients to re-download a new version if I make any important changes. This is great, but I would love to have an easy way to do this with Minified-on-the-fly requests (something like `/min/f=/js/myjavascript.js;v15`).

I could add a variable to the query string, but some browsers and proxies do not cache resources that contain a query string.