revalidatedPolicy(request, response) {
        this._assertRequestHasHeaders(request);
        if(this._useStaleIfError() && isErrorResponse(response)) {  // I consider the revalidation request unsuccessful
          return {
            modified: false,
            matches: false,
            policy: this,
          };
        }
        if (!response || !response.headers) {
            throw Error('Response headers missing');
        }

        // These aren't going to be supported exactly, since one CachePolicy object
        // doesn't know about all the other cached objects.
        let matches = false;
        if (response.status !== undefined && response.status != 304) {
            matches = false;
        } else if (
            response.headers.etag &&
            !/^\s*W\//.test(response.headers.etag)
        ) {
            // "All of the stored responses with the same strong validator are selected.
            // If none of the stored responses contain the same strong validator,
            // then the cache MUST NOT use the new response to update any stored responses."
            matches =
                this._resHeaders.etag &&
                this._resHeaders.etag.replace(/^\s*W\//, '') ===
                    response.headers.etag;
        } else if (this._resHeaders.etag && response.headers.etag) {
            // "If the new response contains a weak validator and that validator corresponds
            // to one of the cache's stored responses,
            // then the most recent of those matching stored responses is selected for update."
            matches =
                this._resHeaders.etag.replace(/^\s*W\//, '') ===
                response.headers.etag.replace(/^\s*W\//, '');
        } else if (this._resHeaders['last-modified']) {
            matches =
                this._resHeaders['last-modified'] ===
                response.headers['last-modified'];
        } else {
            // If the new response does not include any form of validator (such as in the case where
            // a client generates an If-Modified-Since request from a source other than the Last-Modified
            // response header field), and there is only one stored response, and that stored response also
            // lacks a validator, then that stored response is selected for update.
            if (
                !this._resHeaders.etag &&
                !this._resHeaders['last-modified'] &&
                !response.headers.etag &&
                !response.headers['last-modified']
            ) {
                matches = true;
            }
        }

        if (!matches) {
            return {
                policy: new this.constructor(request, response),
                // Client receiving 304 without body, even if it's invalid/mismatched has no option
                // but to reuse a cached body. We don't have a good way to tell clients to do
                // error recovery in such case.
                modified: response.status != 304,
                matches: false,
            };
        }

        // use other header fields provided in the 304 (Not Modified) response to replace all instances
        // of the corresponding header fields in the stored response.
        const headers = {};
        for (const k in this._resHeaders) {
            headers[k] =
                k in response.headers && !excludedFromRevalidationUpdate[k]
                    ? response.headers[k]
                    : this._resHeaders[k];
        }

        const newResponse = Object.assign({}, response, {
            status: this._status,
            method: this._method,
            headers,
        });
        return {
            policy: new this.constructor(request, newResponse, {
                shared: this._isShared,
                cacheHeuristic: this._cacheHeuristic,
                immutableMinTimeToLive: this._immutableMinTtl,
            }),
            modified: false,
            matches: true,
        };
    }
/**
     * Creates new CachePolicy with information combined from the previews response,
     * and the new revalidation response.
     *
     * Returns {policy, modified} where modified is a boolean indicating
     * whether the response body has been modified, and old cached body can't be used.
     *
     * @return {Object} {policy: CachePolicy, modified: Boolean}
     */
Creates new CachePolicy with information combined from the previews response,
and the new revalidation response.

Returns {policy, modified} where modified is a boolean indicating
whether the response body has been modified, and old cached body can't be used.

@return {Object} {policy: CachePolicy, modified: Boolean}
Creates new CachePolicy with information combined from the previews response and the new revalidation response . Returns { policy modified } where modified is a boolean indicating whether the response body has been modified and old cached body can ' t be used . @return { Object } { policy : CachePolicy modified : Boolean }
revalidatedPolicy(request, response) {
        this._assertRequestHasHeaders(request);
        if(this._useStaleIfError() && isErrorResponse(response)) {  
          return {
            modified: false,
            matches: false,
            policy: this,
          };
        }
        if (!response || !response.headers) {
            throw Error('Response headers missing');
        }
        let matches = false;
        if (response.status !== undefined && response.status != 304) {
            matches = false;
        } else if (
            response.headers.etag &&
            !/^\s*W\//.test(response.headers.etag)
        ) {
            matches =
                this._resHeaders.etag &&
                this._resHeaders.etag.replace(/^\s*W\//, '') ===
                    response.headers.etag;
        } else if (this._resHeaders.etag && response.headers.etag) {
            matches =
                this._resHeaders.etag.replace(/^\s*W\//, '') ===
                response.headers.etag.replace(/^\s*W\//, '');
        } else if (this._resHeaders['last-modified']) {
            matches =
                this._resHeaders['last-modified'] ===
                response.headers['last-modified'];
        } else {
            if (
                !this._resHeaders.etag &&
                !this._resHeaders['last-modified'] &&
                !response.headers.etag &&
                !response.headers['last-modified']
            ) {
                matches = true;
            }
        }
        if (!matches) {
            return {
                policy: new this.constructor(request, response),
                modified: response.status != 304,
                matches: false,
            };
        }
        const headers = {};
        for (const k in this._resHeaders) {
            headers[k] =
                k in response.headers && !excludedFromRevalidationUpdate[k]
                    ? response.headers[k]
                    : this._resHeaders[k];
        }
        const newResponse = Object.assign({}, response, {
            status: this._status,
            method: this._method,
            headers,
        });
        return {
            policy: new this.constructor(request, newResponse, {
                shared: this._isShared,
                cacheHeuristic: this._cacheHeuristic,
                immutableMinTimeToLive: this._immutableMinTtl,
            }),
            modified: false,
            matches: true,
        };
    }
revalidatedPolicy ( request , response ) { this . _assertRequestHasHeaders ( request ) ; if ( this . _useStaleIfError ( ) && isErrorResponse ( response ) ) { return { modified : false , matches : false , policy : this , } ; } if ( ! response || ! response . headers ) { throw Error ( 'Response headers missing' ) ; } let matches = false ; if ( response . status !== undefined && response . status != 304 ) { matches = false ; } else if ( response . headers . etag && ! / ^\s*W\/ / . test ( response . headers . etag ) ) { matches = this . _resHeaders . etag && this . _resHeaders . etag . replace ( / ^\s*W\/ / , '' ) === response . headers . etag ; } else if ( this . _resHeaders . etag && response . headers . etag ) { matches = this . _resHeaders . etag . replace ( / ^\s*W\/ / , '' ) === response . headers . etag . replace ( / ^\s*W\/ / , '' ) ; } else if ( this . _resHeaders [ 'last-modified' ] ) { matches = this . _resHeaders [ 'last-modified' ] === response . headers [ 'last-modified' ] ; } else { if ( ! this . _resHeaders . etag && ! this . _resHeaders [ 'last-modified' ] && ! response . headers . etag && ! response . headers [ 'last-modified' ] ) { matches = true ; } } if ( ! matches ) { return { policy : new this . constructor ( request , response ) , modified : response . status != 304 , matches : false , } ; } const headers = { } ; for ( const k in this . _resHeaders ) { headers [ k ] = k in response . headers && ! excludedFromRevalidationUpdate [ k ] ? response . headers [ k ] : this . _resHeaders [ k ] ; } const newResponse = Object . assign ( { } , response , { status : this . _status , method : this . _method , headers , } ) ; return { policy : new this . constructor ( request , newResponse , { shared : this . _isShared , cacheHeuristic : this . _cacheHeuristic , immutableMinTimeToLive : this . _immutableMinTtl , } ) , modified : false , matches : true , } ; }
Creates new CachePolicy with information combined from the previews response,
 and the new revalidation response.
Creates new CachePolicy with information combined from the previews response and the new revalidation response .
// I consider the revalidation request unsuccessful // These aren't going to be supported exactly, since one CachePolicy object // doesn't know about all the other cached objects. // "All of the stored responses with the same strong validator are selected. // If none of the stored responses contain the same strong validator, // then the cache MUST NOT use the new response to update any stored responses." // "If the new response contains a weak validator and that validator corresponds // to one of the cache's stored responses, // then the most recent of those matching stored responses is selected for update." // If the new response does not include any form of validator (such as in the case where // a client generates an If-Modified-Since request from a source other than the Last-Modified // response header field), and there is only one stored response, and that stored response also // lacks a validator, then that stored response is selected for update. // Client receiving 304 without body, even if it's invalid/mismatched has no option // but to reuse a cached body. We don't have a good way to tell clients to do // error recovery in such case. // use other header fields provided in the 304 (Not Modified) response to replace all instances // of the corresponding header fields in the stored response.