| 15 | } |
| 16 | |
| 17 | interface CacheControlOptions { |
| 18 | // Cacheability |
| 19 | public?: boolean; // Allow caching in both browsers and CDNs |
| 20 | private?: boolean; // Allow caching only in browsers, not CDNs |
| 21 | |
| 22 | // No caching |
| 23 | noCache?: boolean; // Cache exists but verifies with server every time |
| 24 | noStore?: boolean; // Don't cache at all, fetch fresh every time |
| 25 | |
| 26 | // Freshness (in seconds) |
| 27 | maxAge?: number; // How long browsers should keep cache without checking server |
| 28 | sMaxAge?: number; // How long CDNs should keep cache without checking server |
| 29 | |
| 30 | // Stale content handling (in seconds) |
| 31 | staleWhileRevalidate?: number; // Show old cache while fetching new data in background |
| 32 | staleIfError?: number; // Show old cache if server fails to respond |
| 33 | |
| 34 | // Revalidation |
| 35 | mustRevalidate?: boolean; // Force check with server when cache expires (both cdn and browser) |
| 36 | proxyRevalidate?: boolean; // Force only CDNs to check with server when cache expires |
| 37 | |
| 38 | // Other directives |
| 39 | immutable?: boolean; // Content won't change while cache is valid |
| 40 | noTransform?: boolean; // Don't allow CDNs to modify the response |
| 41 | } |
| 42 | |
| 43 | export function setCacheHeaders( |
| 44 | res: NextApiResponse, |
nothing calls this directly
no outgoing calls
no test coverage detected