1

My application is growing, changing, and deploying to our alpha users several at least once a day. This leads to a problem as users' browsers caches doesn't expire rapidly enough for them to get the latest script versions.

What are some good ways of dealing with this? I know I could add a cachebuster querystring parameter (depending on our mercurial revision) to the script files but that seems like a hack and would require extending requirejs to implement.

Is there some sort of cache expiration headers we could configure on the server that modern browsers would honor? (our alpha users are all on Chrome ore Firefox)

George Mauer
  • 117,483
  • 131
  • 382
  • 612
  • http://stackoverflow.com/q/8315088/139010 – Matt Ball Apr 11 '13 at 04:06
  • Appreciate that @MattBall that's great to know. I would like to know if there's an HTTP-native way of solving the issue though. – George Mauer Apr 11 '13 at 04:07
  • What web server are you using? – Leopd Apr 11 '13 at 04:40
  • @Leopd it's a Asp.Net Mvc app so Iis – George Mauer Apr 11 '13 at 04:41
  • 1
    If you do not wish to implement cache buster, you can set expires header from your webserver, or add a plugin/addon for chrome / firefox that disables cache. on your webserver you can set: `Cache-Control: no-cache, no-store, must-revalidate Pragma: no-cache Expires: 0` – Dev Shangari Apr 11 '13 at 04:43
  • My method is to run a script that minifys any necessary JS files and changes the name of each to the hash of its file contents. If you save the new files in a separate directory you can simply just loop that directory or tell `require.js` to retrieve from `said directory` (if thats possible, I don't use require.js). – anson Apr 11 '13 at 04:57

1 Answers1

0

I know you're running IIS, but if you're willing to set up Apache as a reverse proxy, you could run Google's mod_pagespeed plugin. It automatically rewrites your HTML on the way out, adding cache-busting parameters, and setting appropriate long-lived cache control HTTP headers on all the JS content. It's really slick.

Leopd
  • 41,333
  • 31
  • 129
  • 167