Ryan
Ryan

Reputation: 143

RequireJS Caching

We are having some trouble with RequireJS not grabbing a fresh copy each time it is requested. We have used the following without success:

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

When viewing the network log, the page is loaded with the argument appended to the URL, however if the same page is called again, it doesn't appear in the network log at all, so it is coming from the cache somehow.

If anyone has any ideas, it would be greatly appreciated.

Thanks, Ryan.

Upvotes: 1

Views: 1897

Answers (1)

Paul Grime
Paul Grime

Reputation: 15104

This jsfiddle example shows urlArgs working.

require.config({
    urlArgs: "bust=" + (new Date()).getTime(),
    paths: {
        "jquery": "http://code.jquery.com/jquery-1.9.1"
    }
});

require(["module", "jquery"], function (module, $) {
    console.log($.fn.jquery);
    console.log(module, module.config());
});

With this output:

1.9.1
Object { id="_@r5", uri="./[email protected]?bust=1365059426478", config=function()} Object {}

And the Net panel in Firebug shows a fresh version of jQuery downloaded each time.

Firebug Net Panel

Which browser(s) are you using?

Upvotes: 2

Related Questions