@@ -87,7 +87,6 @@ module.exports = class CachePolicy {
8787 cacheHeuristic,
8888 immutableMinTimeToLive,
8989 ignoreCargoCult,
90- trustServerDate,
9190 _fromObject,
9291 } = { }
9392 ) {
@@ -103,8 +102,6 @@ module.exports = class CachePolicy {
103102
104103 this . _responseTime = this . now ( ) ;
105104 this . _isShared = shared !== false ;
106- this . _trustServerDate =
107- undefined !== trustServerDate ? trustServerDate : true ;
108105 this . _cacheHeuristic =
109106 undefined !== cacheHeuristic ? cacheHeuristic : 0.1 ; // 10% matches IE
110107 this . _immutableMinTtl =
@@ -331,24 +328,13 @@ module.exports = class CachePolicy {
331328 }
332329
333330 /**
334- * Value of the Date response header or current time if Date was demed invalid
331+ * Value of the Date response header or current time if Date was invalid
335332 * @return timestamp
336333 */
337334 date ( ) {
338- if ( this . _trustServerDate ) {
339- return this . _serverDate ( ) ;
340- }
341- return this . _responseTime ;
342- }
343-
344- _serverDate ( ) {
345335 const serverDate = Date . parse ( this . _resHeaders . date ) ;
346336 if ( isFinite ( serverDate ) ) {
347- const maxClockDrift = 8 * 3600 * 1000 ;
348- const clockDrift = Math . abs ( this . _responseTime - serverDate ) ;
349- if ( clockDrift < maxClockDrift ) {
350- return serverDate ;
351- }
337+ return serverDate ;
352338 }
353339 return this . _responseTime ;
354340 }
@@ -360,11 +346,7 @@ module.exports = class CachePolicy {
360346 * @return Number
361347 */
362348 age ( ) {
363- let age = Math . max ( 0 , ( this . _responseTime - this . date ( ) ) / 1000 ) ;
364- if ( this . _resHeaders . age ) {
365- let ageValue = this . _ageValue ( ) ;
366- if ( ageValue > age ) age = ageValue ;
367- }
349+ let age = this . _ageValue ( ) ;
368350
369351 const residentTime = ( this . now ( ) - this . _responseTime ) / 1000 ;
370352 return age + residentTime ;
@@ -419,7 +401,7 @@ module.exports = class CachePolicy {
419401
420402 const defaultMinTtl = this . _rescc . immutable ? this . _immutableMinTtl : 0 ;
421403
422- const serverDate = this . _serverDate ( ) ;
404+ const serverDate = this . date ( ) ;
423405 if ( this . _resHeaders . expires ) {
424406 const expires = Date . parse ( this . _resHeaders . expires ) ;
425407 // A cache recipient MUST interpret invalid date formats, especially the value "0", as representing a time in the past (i.e., "already expired").
@@ -644,7 +626,6 @@ module.exports = class CachePolicy {
644626 shared : this . _isShared ,
645627 cacheHeuristic : this . _cacheHeuristic ,
646628 immutableMinTimeToLive : this . _immutableMinTtl ,
647- trustServerDate : this . _trustServerDate ,
648629 } ) ,
649630 modified : false ,
650631 matches : true ,
0 commit comments