Skip to content Skip to sidebar Skip to footer

Javascript:: How To Prevent Caching In Xmlhttprequest From Js?

Possible Duplicate: How to prevent Ajax/javascript result caching in browsers? I want to load JS-script dynamically. Every time browser load old version of file? How to prevent

Solution 1:

For the random number part as suggested by sandeepraju:

var url = "jsfile.js?" + newDate().getTime();

Solution 2:

Easiest way would be to send the request by sending a random number as parameter each time so that browser does not cache the request!

Example:

<scripttype="text/javascript"src="somejsfile.js?r=random_number"></script>

a random number can be generated each time by a script which loads before this!

I'm not sure if this is the right way, but it does the job fine!

Post a Comment for "Javascript:: How To Prevent Caching In Xmlhttprequest From Js?"