urlArgs
配置值;RequireJS将为您添加查询字符串。urlArgs: "bust=" + (new Date()).getTime()
(new Date()).getTime()
这部分只是JavaScript中获取唯一字符串的简单方法。你可以使用Math.random()
的变化,但使用自纪元以来的毫秒数可以保证唯一性,以实现最佳缓存破坏。
我认为Burke先生是在建议类似于:
require.config({
baseUrl: '/base/path',
paths: {
'fileAlias': 'fileLikelyToChange?bust=' + (new Date()).getTime(),
'anotherFileAlias': 'anotherFileLikelyToChange?bust=' + (new Date()).getTime(),
'jQuery': 'jQuery'
},
});
function bust(path) {
return path + '?bust=' + (new Date()).getTime();
}
require.config({
baseUrl: '/base/path',
paths: {
'fileAlias': bust('fileLikelyToChange'),
'anotherFileAlias': bust('anotherFileLikelyToChange'),
'jQuery': 'jQuery'
},
});