@ -379,9 +379,25 @@ module.exports = class CachePolicy {
headers [ 'if-none-match' ] = headers [ 'if-none-match' ] ? ` ${ headers [ 'if-none-match' ] } , ${ this . _ resHeaders . etag } ` : this . _ resHeaders . etag ;
}
// Clients MAY issue simple (non-subrange) GET requests with either weak validators or strong validators. Clients MUST NOT use weak validators in other forms of request.
const forbidsWeakValidators = headers [ 'accept-ranges' ] || headers [ 'if-match' ] || headers [ 'if-unmodified-since' ] || ( this . _ method && this . _ method != 'GET' ) ;
/ * S H O U L D s e n d t h e L a s t - M o d i f i e d v a l u e i n n o n - s u b r a n g e c a c h e v a l i d a t i o n r e q u e s t s ( u s i n g I f - M o d i f i e d - S i n c e ) i f o n l y a L a s t - M o d i f i e d v a l u e h a s b e e n p r o v i d e d b y t h e o r i g i n s e r v e r .
Note : This implementation does not understand partial responses ( 206 ) * /
if ( this . _ resHeaders [ 'last-modified' ] && ! headers [ 'if-modified-since' ] ) {
if ( forbidsWeakValidators ) {
delete headers [ 'if-modified-since' ] ;
if ( headers [ 'if-none-match' ] ) {
const etags = headers [ 'if-none-match' ] . split ( /,/ ) . filter ( etag => {
return ! /^\s*W\// . test ( etag ) ;
} ) ;
if ( ! etags . length ) {
delete headers [ 'if-none-match' ] ;
} else {
headers [ 'if-none-match' ] = etags . join ( ',' ) . trim ( ) ;
}
}
} else if ( this . _ resHeaders [ 'last-modified' ] && ! headers [ 'if-modified-since' ] ) {
headers [ 'if-modified-since' ] = this . _ resHeaders [ 'last-modified' ] ;
}