Add no-store cache header for zip downloads
This commit is contained in:
@@ -136,6 +136,7 @@ function startZipResponse (res: Response, share: SharedLink, archive: Archiver)
|
||||
res.setHeader('Content-Disposition', `attachment; filename*=UTF-8''${filename}`)
|
||||
// Hint to intermediate proxies (Nginx, etc.) not to buffer this response.
|
||||
res.setHeader('X-Accel-Buffering', 'no')
|
||||
res.setHeader('Cache-Control', 'no-store')
|
||||
archive.pipe(res)
|
||||
}
|
||||
|
||||
|
||||
@@ -161,6 +161,9 @@ describe('downloadAssets', () => {
|
||||
await downloadAssets(asResponse(res), share, [makeAsset('a1'), makeAsset('a2')])
|
||||
expect(res.writableFinished).toBe(true)
|
||||
expect(res.headers['Content-Type']).toBe('application/zip')
|
||||
// A CDN must never store the zip; Cloudflare's cache fill aborts large
|
||||
// downloads partway through otherwise #94
|
||||
expect(res.headers['Cache-Control']).toBe('no-store')
|
||||
const zip = res.output
|
||||
expect(countOf(zip, 'PK\x03\x04')).toBe(2) // local file headers
|
||||
expect(countOf(zip, 'PK\x05\x06')).toBe(1) // end of central directory
|
||||
|
||||
Reference in New Issue
Block a user