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:
Bart Nagel
2016-06-27 21:46:14 -07:00
committed by Maxime Thirouin
parent ee530f4c0a
commit 7976f06043
5 changed files with 43 additions and 10 deletions

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