Caching in browsers

The other day at work we ran into a problem with users updating to the newest version of our software.

Our main program queries a server with the version number and receives an address from where the newest installer can be fetched. The program then launches a browser that downloads and runs (on the users request) the installer – bam! Updated!

So we thought – but it turns out that we made a minor mistake (I’m gonna claim that it is a browser misbehaving ’till the end of days!) that caused the older version to be downloaded instead. The case was this:

We always point a user to a static address containing the newest version. The static address is a PHP script redirecting to the right/newest version. The redirect was done with a HTTP 301 (moved permanently) and therein was the error! See (this is tested in Chrome and Chrome only) when the browser sees that the address it is GET’ing is moved permanently it decides to cache the multi-MB install file. When the user returns a week-or-so later GET’ing the same static address (now redirecting by 301 to a new address) the browser (Chrome!) don’t really bother actually performing the GET – it just assume that that address has moved permanently and therefore we GET the address that it was previously resolved to!

Ouch! Users where stuck in an endless update cycle! I wrote a short piece about it on our company weblog to help users update properly.

Needless to say we changed the PHP script doing the redirect – and made some small adjustments to do avoid this type of problems!