Unwanted underscores and unix timestamps appearing after javascript include

On pages loaded using the jquery download function, all included javascript files contain the argument '_' with a value equal to the current unix timestamp, and 3 additional numbers when loading them.

For example, if I include the file "file.js", the actual file to be included will be "file.js? _ = 1378360893522".

This prevents caching of javascript files, is there a way to stop this behavior?

Edit: As requested, here is the code:

index.html

<html> <head> <script type="text/javascript" src="js/jquery.min.js"></script> </head> <body> <div id='new-page'></div> </body> <script> $(document).ready(function() { $('#new-page').load("another-page.html"); }); </script> </html> 

other-page.html:

 <html> <head> <script type="text/javascript" src="js/another-js-file.js"></script> </head> <body> </body> </html> 

"another-js-file.js" loads as "another-js-file.js? _ = 1378425747710"

Second edit: This was answered. For those reading this, I modified my load call to be something more similar:

 $.ajax({ url: "another-page.html", cache: true, dataType: "html", success: function(data){ $("#new-page").html(data); } }); 

Some people have stated that some plugins can set the cache as false via ajaxSetup, so you may need to use this before calling the ajax that you want to cache:

 $.ajaxSetup({cache:true}); 
+4
source share
1 answer

Your problem is well documented and a solution can be made from:

jQuery version 1.5 - ajax - <script> timestamp tag

The solution involves using the cache option in a jQuery AJAX call.

+4
source

Source: https://habr.com/ru/post/1500831/


All Articles