MCPcopy Create free account
hub / github.com/nodejs/node / needsRevalidation

Function needsRevalidation

deps/undici/src/lib/interceptor/cache.js:41–58  ·  view source on GitHub ↗

* @param {import('../../types/cache-interceptor.d.ts').default.GetResult} result * @param {import('../../types/cache-interceptor.d.ts').default.CacheControlDirectives | undefined} cacheControlDirectives * @param {import('../../types/dispatcher.d.ts').default.RequestOptions} opts * @returns {boole

(result, cacheControlDirectives, { headers = {} })

Source from the content-addressed store, hash-verified

39 * @returns {boolean}
40 */
41function needsRevalidation (result, cacheControlDirectives, { headers = {} }) {
42 // Always revalidate requests with the no-cache request directive.
43 if (cacheControlDirectives?.['no-cache']) {
44 return true
45 }
46
47 // Always revalidate requests with unqualified no-cache response directive.
48 if (result.cacheControlDirectives?.['no-cache'] && !Array.isArray(result.cacheControlDirectives['no-cache'])) {
49 return true
50 }
51
52 // Always revalidate requests with conditional headers.
53 if (headers['if-modified-since'] || headers['if-none-match']) {
54 return true
55 }
56
57 return false
58}
59
60/**
61 * @param {import('../../types/cache-interceptor.d.ts').default.GetResult} result

Callers 1

handleResultFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected