Im working on bookmarklets and my issue is js not getting update
I load js file with my bookmarklet, And my problem is its not getting update with my latest version. even also if i have updated it in my database.
So what i want it to check and load latest version when ever bookmark is clicked. so i want to know if there something to add in js file so it get load latest version. Or if there is way to check date and time or check version. etc
I have no problem with codes as they working fine.
Suppose this is my js
function start() {
// codes
};
// ---------------------------------------
// Ajax
// ---------------------------------------
function AJAXInteraction(url, callback) {
var req = init();
req.onreadystatechange = processRequest;
function init() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
}
else if (window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
}
}
function processRequest() {
if (req.readyState == 4) {
if (req.status == 200) {
if (callback) callback(req.responseText);
}
}
}
this.doGet = function () {
req.open("GET", url, true);
req.send(null);
}
this.doPost = function (str) {
req.open("POST", url, true);
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
req.send(str);
}
};
If you are appending a JS file to the page and you want to force your browser to always get a fresh copy of the file and not use the cache, then you can append any random text as part of the query string. Here is example code.
Alternatively, the server from which the file is being loaded could specify certain expiration information. To ensure you always get the latest, you could specify an expiration of sometime in the past.
Take a look at this: Setup HTTP expires headers using PHP and Apache