Question

A client would report a bug in our JS-heavy app, we fixed it, but the client's browser still using the cached copy. This happens a lot, and asking our clients to flush their browser cache seems very low-tech and troublesome.

We are aware of the ?ver=xxx workaround, but we use RequireJS so it's not easy to apply such hack.

Would HTTP cache control work? However, we noticed IIS does not pick up the JS file changes right away and the HTTP header (last modified) does not reflect the latest changes.

Would ETag work better? Is it better or worse then last modified on IIS?

Any other solutions? Thanks

Was it helpful?

Solution

RequireJS has a cache busting property that you can use -:

require.config({
    urlArgs: "bust=" + (new Date()).getTime()
});

Edit -: However, as Ian pointed out below, in their documents it is recommended not to use it this way for production code.

Everytime you push a new commit to production maybe you can instead add a specific version number.

require.config({
        urlArgs: "ver=1.1.1"
    });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top