diff --git a/fetch.js b/fetch.js index f88488cd..ef714825 100644 --- a/fetch.js +++ b/fetch.js @@ -358,6 +358,21 @@ export function Request(input, options) { throw new TypeError('Body not allowed for GET or HEAD requests') } this._initBody(body) + + if (this.method === 'GET' || this.method === 'HEAD') { + if (options.cache === 'no-store' || options.cache === 'no-cache') { + // Search for a '_' parameter in the query string + var reParamSearch = /([?&])_=[^&]*/ + if (reParamSearch.test(this.url)) { + // If it already exists then set the value with the current time + this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime()) + } else { + // Otherwise add a new '_' parameter to the end with the current time + var reQueryString = /\?/ + this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime() + } + } + } } Request.prototype.clone = function() {