Make cache-busting optional

Closes #70
This commit is contained in:
Bart Nagel
2016-06-24 01:55:15 -07:00
parent 7cdcf3c887
commit 06473cb739
5 changed files with 33 additions and 3 deletions

View File

@@ -19,6 +19,7 @@ module.exports = function(options){
}
}
this.options.scrollTo = (typeof this.options.scrollTo === 'undefined') ? 0 : this.options.scrollTo;
this.options.cacheBust = (typeof this.options.cacheBust === 'undefined') ? true : this.options.cacheBust
this.options.debug = this.options.debug || false
// we cant replace body.outerHTML or head.outerHTML

View File

@@ -12,7 +12,12 @@ module.exports = function(location, callback) {
}
}
request.open("GET", location + (!/[?&]/.test(location) ? "?" : "&") + (new Date().getTime()), true)
// Add a timestamp as part of the query string if cache busting is enabled
if (this.options.cacheBust) {
location += (!/[?&]/.test(location) ? "?" : "&") + new Date().getTime()
}
request.open("GET", location, true)
request.setRequestHeader("X-Requested-With", "XMLHttpRequest")
request.send(null)
return request