@@ -87,7 +87,6 @@ module.exports = class CachePolicy {
87
87
cacheHeuristic,
88
88
immutableMinTimeToLive,
89
89
ignoreCargoCult,
90
- trustServerDate,
91
90
_fromObject,
92
91
} = { }
93
92
) {
@@ -103,8 +102,6 @@ module.exports = class CachePolicy {
103
102
104
103
this . _responseTime = this . now ( ) ;
105
104
this . _isShared = shared !== false ;
106
- this . _trustServerDate =
107
- undefined !== trustServerDate ? trustServerDate : true ;
108
105
this . _cacheHeuristic =
109
106
undefined !== cacheHeuristic ? cacheHeuristic : 0.1 ; // 10% matches IE
110
107
this . _immutableMinTtl =
@@ -331,24 +328,13 @@ module.exports = class CachePolicy {
331
328
}
332
329
333
330
/**
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
335
332
* @return timestamp
336
333
*/
337
334
date ( ) {
338
- if ( this . _trustServerDate ) {
339
- return this . _serverDate ( ) ;
340
- }
341
- return this . _responseTime ;
342
- }
343
-
344
- _serverDate ( ) {
345
335
const serverDate = Date . parse ( this . _resHeaders . date ) ;
346
336
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 ;
352
338
}
353
339
return this . _responseTime ;
354
340
}
@@ -360,11 +346,7 @@ module.exports = class CachePolicy {
360
346
* @return Number
361
347
*/
362
348
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 ( ) ;
368
350
369
351
const residentTime = ( this . now ( ) - this . _responseTime ) / 1000 ;
370
352
return age + residentTime ;
@@ -419,7 +401,7 @@ module.exports = class CachePolicy {
419
401
420
402
const defaultMinTtl = this . _rescc . immutable ? this . _immutableMinTtl : 0 ;
421
403
422
- const serverDate = this . _serverDate ( ) ;
404
+ const serverDate = this . date ( ) ;
423
405
if ( this . _resHeaders . expires ) {
424
406
const expires = Date . parse ( this . _resHeaders . expires ) ;
425
407
// 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 {
644
626
shared : this . _isShared ,
645
627
cacheHeuristic : this . _cacheHeuristic ,
646
628
immutableMinTimeToLive : this . _immutableMinTtl ,
647
- trustServerDate : this . _trustServerDate ,
648
629
} ) ,
649
630
modified : false ,
650
631
matches : true ,
0 commit comments