Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add extension cache-control directives #4325

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/hint-http-cache/src/hint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ export default class HttpCacheHint implements IHint {
// https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
const directives = ['must-revalidate', 'no-cache', 'no-store', 'no-transform', 'public', 'private', 'proxy-revalidate'];
const valueDirectives = ['max-age', 's-maxage'];
const extensionDirectives = ['immutable', 'stale-while-revalidate', 'stale-if-error'];
const extensionDirectives = ['immutable'];
const extensionValueDirectives = ['stale-while-revalidate', 'stale-if-error'];

const usedDirectives = cacheControlHeader.split(',').map((value) => {
return value.trim();
Expand All @@ -162,7 +163,7 @@ export default class HttpCacheHint implements IHint {
* Check if the directive has a value when it shouldn't
* E.g.: no-cache=12345
*/
if (!valueDirectives.includes(directive)) {
if (!valueDirectives.includes(directive) && !extensionValueDirectives.includes(directive)) {
parsed.invalidValues.set(directive, value);

return parsed;
Expand Down