When loading content through AJAX which contains an externally linked Javascript file or when using jQuery.getScript() function call, the linked Javascript files are appended with a cache busting parameter, which prevents the file from being cached by the browser.
So, instead of writing something like <script src="/js/foo.js">
, it writes something like <script src="/js/foo.js?_=ts2477874287">
, causing the script to be loaded fresh each time.
Is there a way to disable this and have the file cached when it's loaded?
I don't know about getScript, but cache
is a parameter you can set in a .ajax()
parameter map. It's false by default for scripts but you can flip it to true. Once false, it won't append a cache-busting query string.
[updated per comment]