@@ -226,6 +226,15 @@ module.exports = class CachePolicy {
226226 satisfiesWithoutRevalidation ( req ) {
227227 this . _assertRequestHasHeaders ( req ) ;
228228
229+ // In all circumstances, a cache MUST NOT ignore the must-revalidate directive
230+ if ( this . _rescc [ 'must-revalidate' ] ) {
231+ return false ;
232+ }
233+
234+ if ( ! this . _requestMatches ( req , false ) ) {
235+ return false ;
236+ }
237+
229238 // When presented with a request, a cache MUST NOT reuse a stored response, unless:
230239 // the presented request does not contain the no-cache pragma (Section 5.4), nor the no-cache cache directive,
231240 // unless the stored response is successfully validated (Section 4.3), and
@@ -248,17 +257,15 @@ module.exports = class CachePolicy {
248257 // the stored response is either:
249258 // fresh, or allowed to be served stale
250259 if ( this . stale ( ) ) {
251- const allowsStale =
252- requestCC [ 'max-stale' ] &&
253- ! this . _rescc [ 'must-revalidate' ] &&
254- ( true === requestCC [ 'max-stale' ] ||
255- requestCC [ 'max-stale' ] > this . age ( ) - this . maxAge ( ) ) ;
260+ const allowsStale = requestCC [ 'max-stale' ] &&
261+ ( true === requestCC [ 'max-stale' ] || requestCC [ 'max-stale' ] > this . age ( ) - this . maxAge ( ) ) ;
262+
256263 if ( ! allowsStale ) {
257264 return false ;
258265 }
259266 }
260267
261- return this . _requestMatches ( req , false ) ;
268+ return true ;
262269 }
263270
264271 _requestMatches ( req , allowHeadMethod ) {
0 commit comments