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 ofmain.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.