4

We need to implement cache busting for our RequireJS modules, but it needs to be done such that it can still leverage proxy caching.

This Google best practices article talks about not using querystring data for versioning your URLs.

Also, this discussion points to this article that explains how to implement cache busting by versioning filenames and using URL rewrites to strip the version from the filename.

But this approach won't work for RequireJS modules.

Has anyone implemented cache busting for RequireJS modules that supports proxy caching?

Update: I just found this article, but it again talks about using RequireJS urlArgs for versioning via querystring. Won't this defeat proxy caching?

Update 2: Unfortunately, I was right. According to that article, urlArgs will indeed defeat proxy caching:

The optimal cache busting method involves changing the file name itself, such as main.1.1.0.0.js instead of main.js?v=1.1.0.0. There are several packages that will do this for you on the fly (example), but they don't integrate with RequireJS. So we'll stick with query strings in the rest of this article.

Community
  • 1
  • 1
Jerad Rose
  • 15,235
  • 18
  • 82
  • 153
  • 1
    if changing filenames is effective then wouldn't it work to make the version number part of the path to your files? /path//main.js this approach would be quite easy to integrate into your build process. – neonstalwart Sep 21 '13 at 04:01
  • I would suggest my solution, posted here: http://stackoverflow.com/a/21619359/1017787 would satisfy your request for an optimal method. – JBCP Feb 07 '14 at 04:30
  • possible duplicate of [Prevent RequireJS from Caching Required Scripts](http://stackoverflow.com/questions/8315088/prevent-requirejs-from-caching-required-scripts) – JBCP Feb 07 '14 at 04:30

0 Answers0