Lines Matching refs:response
69 function isErrorResponse(response) {
70 // consider undefined response as faulty
71 if(!response) {
74 return errorStatusCodes.has(response.status);
179 // The "no-store" request directive indicates that a cache MUST NOT store any part of either this request or any response to it.
182 // A cache MUST NOT store a response to any request, unless:
187 // the response status code is understood by the cache, and
189 // the "no-store" cache directive does not appear in request or response header fields, and
191 // the "private" response directive does not appear in the response, if the cache is shared, and
197 // the response either:
200 // contains a max-age response directive, or
201 // contains a s-maxage response directive and the cache is shared, or
202 // contains a public response directive.
229 // When presented with a request, a cache MUST NOT reuse a stored response, unless:
231 // unless the stored response is successfully validated (Section 4.3), and
248 // the stored response is either:
265 // The presented effective request URI and that of the stored response match, and
269 // the request method associated with the stored response allows it to be used for the presented request, and
273 // selecting header fields nominated by the stored response (if any) match those presented, and
279 // following Cache-Control response directives (Section 5.2.2) have such an effect: must-revalidate, public, and s-maxage.
338 // lifetime greater than 24 hours and the response's age is greater than 24 hours.
354 * Value of the Date response header or current time if Date was invalid
383 * Value of applicable max-age (or heuristic equivalent) in seconds. This counts since response's `Date`.
413 // if a response includes the s-maxage directive, a shared cache recipient MUST ignore the Expires field.
419 // If a response includes a Cache-Control field with the max-age directive, a recipient MUST ignore the Expires field.
512 * Headers for sending to the origin server to revalidate stale response.
513 * Allows server to return 304 to allow reuse of the previous response.
575 * Creates new CachePolicy with information combined from the previews response,
576 * and the new revalidation response.
579 * whether the response body has been modified, and old cached body can't be used.
583 revalidatedPolicy(request, response) {
585 if(this._useStaleIfError() && isErrorResponse(response)) { // I consider the revalidation request unsuccessful
592 if (!response || !response.headers) {
599 if (response.status !== undefined && response.status != 304) {
602 response.headers.etag &&
603 !/^\s*W\//.test(response.headers.etag)
607 // then the cache MUST NOT use the new response to update any stored responses."
611 response.headers.etag;
612 } else if (this._resHeaders.etag && response.headers.etag) {
613 // "If the new response contains a weak validator and that validator corresponds
618 response.headers.etag.replace(/^\s*W\//, '');
622 response.headers['last-modified'];
624 // If the new response does not include any form of validator (such as in the case where
626 // response header field), and there is only one stored response, and that stored response also
627 // lacks a validator, then that stored response is selected for update.
631 !response.headers.etag &&
632 !response.headers['last-modified']
640 policy: new this.constructor(request, response),
644 modified: response.status != 304,
649 // use other header fields provided in the 304 (Not Modified) response to replace all instances
650 // of the corresponding header fields in the stored response.
654 k in response.headers && !excludedFromRevalidationUpdate[k]
655 ? response.headers[k]
659 const newResponse = Object.assign({}, response, {