Added: cacheBust option (#71)
* Refactor request test to allow further tests to be added * Make cache-busting optional Closes #70
This commit was merged in pull request #71.
This commit is contained in:
committed by
Maxime Thirouin
parent
ee530f4c0a
commit
7976f06043
@@ -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 can’t replace body.outerHTML or head.outerHTML
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user