1

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.

2
  • The 'page' is loaded, or the module (JS) is loaded with the argument appended?
    – Paul Grime
    Commented Apr 4, 2013 at 7:07
  • Or Math.random() which is shorter and a bit faster. jsperf.com/speedcomparison Commented Jul 24, 2013 at 12:51

1 Answer 1

2

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.