({
revalidate,
expire,
}: CacheControl)
| 15 | } |
| 16 | |
| 17 | export function getCacheControlHeader({ |
| 18 | revalidate, |
| 19 | expire, |
| 20 | }: CacheControl): string { |
| 21 | const swrHeader = |
| 22 | typeof revalidate === 'number' && |
| 23 | expire !== undefined && |
| 24 | revalidate < expire |
| 25 | ? `, stale-while-revalidate=${expire - revalidate}` |
| 26 | : '' |
| 27 | |
| 28 | if (revalidate === 0) { |
| 29 | return 'private, no-cache, no-store, max-age=0, must-revalidate' |
| 30 | } else if (typeof revalidate === 'number') { |
| 31 | return `s-maxage=${revalidate}${swrHeader}` |
| 32 | } |
| 33 | |
| 34 | return `s-maxage=${CACHE_ONE_YEAR_SECONDS}${swrHeader}` |
| 35 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…