* @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 = {} })
| 39 | * @returns {boolean} |
| 40 | */ |
| 41 | function 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 |