(res: Res, caching: Caching)
| 37 | type Res = Pick<S, 'setHeader' | 'statusCode' | 'writeHead'> & NodeJS.WritableStream |
| 38 | |
| 39 | export const enableCaching = (res: Res, caching: Caching) => { |
| 40 | let cc = caching.maxAge != null && `public,max-age=${caching.maxAge}` |
| 41 | if (cc && caching.immutable) cc += ',immutable' |
| 42 | else if (cc && caching.maxAge === 0) cc += ',must-revalidate' |
| 43 | |
| 44 | res.setHeader('Cache-Control', cc) |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Sends a file by piping a stream to response. |
no outgoing calls
no test coverage detected