From 1988c3f0800d5a1f14c8e94c04d8a0c97aae2f51 Mon Sep 17 00:00:00 2001 From: Kornel Date: Sun, 9 Feb 2020 09:53:38 +0000 Subject: [PATCH] Rename var --- index.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 9577212..4992d91 100644 --- a/index.js +++ b/index.js @@ -342,12 +342,12 @@ module.exports = class CachePolicy { } _serverDate() { - const dateValue = Date.parse(this._resHeaders.date); - if (isFinite(dateValue)) { + const serverDate = Date.parse(this._resHeaders.date); + if (isFinite(serverDate)) { const maxClockDrift = 8 * 3600 * 1000; - const clockDrift = Math.abs(this._responseTime - dateValue); + const clockDrift = Math.abs(this._responseTime - serverDate); if (clockDrift < maxClockDrift) { - return dateValue; + return serverDate; } } return this._responseTime; @@ -419,22 +419,22 @@ module.exports = class CachePolicy { const defaultMinTtl = this._rescc.immutable ? this._immutableMinTtl : 0; - const dateValue = this._serverDate(); + const serverDate = this._serverDate(); if (this._resHeaders.expires) { const expires = Date.parse(this._resHeaders.expires); // A cache recipient MUST interpret invalid date formats, especially the value "0", as representing a time in the past (i.e., "already expired"). - if (Number.isNaN(expires) || expires < dateValue) { + if (Number.isNaN(expires) || expires < serverDate) { return 0; } - return Math.max(defaultMinTtl, (expires - dateValue) / 1000); + return Math.max(defaultMinTtl, (expires - serverDate) / 1000); } if (this._resHeaders['last-modified']) { const lastModified = Date.parse(this._resHeaders['last-modified']); - if (isFinite(lastModified) && dateValue > lastModified) { + if (isFinite(lastModified) && serverDate > lastModified) { return Math.max( defaultMinTtl, - ((dateValue - lastModified) / 1000) * this._cacheHeuristic + ((serverDate - lastModified) / 1000) * this._cacheHeuristic ); } }