mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 13:07:08 +00:00
Do not cache any responses containing cookies
This commit is contained in:
@@ -30,11 +30,14 @@ function saveResponse (res) {
|
||||
if (res?.headersSent) {
|
||||
const etag = res.get("ETag");
|
||||
if (etag && res.locals.saveEtag !== false) {
|
||||
if (res.get("set-cookie")) {
|
||||
// Do not save any responses containing cookies
|
||||
return;
|
||||
}
|
||||
const cache = getCache(res);
|
||||
const req = res.req;
|
||||
console.log(`Saving ETag: ${req.method} ${req.url} → ${etag}`);
|
||||
const headers = structuredClone(res.getHeaders());
|
||||
delete headers["set-cookie"];
|
||||
cache[req.url] = {etag, headers};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user