Respect cache-control in guest API cache

This commit is contained in:
Codex Agent
2026-01-30 13:00:19 +01:00
parent 19425c0f62
commit 8aba034344
3 changed files with 48 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
export function shouldCacheResponse(response: Response | null): boolean {
if (!response) {
return false;
}
const cacheControl = response.headers.get('Cache-Control') ?? '';
const pragma = response.headers.get('Pragma') ?? '';
const normalizedCacheControl = cacheControl.toLowerCase();
const normalizedPragma = pragma.toLowerCase();
if (normalizedCacheControl.includes('no-store') || normalizedCacheControl.includes('private')) {
return false;
}
if (normalizedPragma.includes('no-cache')) {
return false;
}
return true;
}