Skip to content

refactor: logic for cacheImmutable#2254

Merged
alexander-akait merged 1 commit intonextfrom
refactor-cache-immutable-logic
Jan 27, 2026
Merged

refactor: logic for cacheImmutable#2254
alexander-akait merged 1 commit intonextfrom
refactor-cache-immutable-logic

Conversation

@alexander-akait
Copy link
Copy Markdown
Member

Summary

refactor logic for #2247

What kind of change does this PR introduce?

refactor

Did you add tests for your changes?

Yes

Does this PR introduce a breaking change?

No

If relevant, what needs to be documented once your changes are merged or what have you already documented?

Nothing

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.85%. Comparing base (47a43b0) to head (19f9cc6).
⚠️ Report is 1 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #2254   +/-   ##
=======================================
  Coverage   95.84%   95.85%           
=======================================
  Files          13       13           
  Lines         891      892    +1     
  Branches      260      260           
=======================================
+ Hits          854      855    +1     
  Misses         37       37           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/middleware.js
if (cacheControl.immutable) {
cacheControlValue += ", immutable";
}
}
Copy link
Copy Markdown
Member Author

@alexander-akait alexander-akait Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bjohansebas

Refactor logic:

  • based on type (boolean, number, string or object) we will write header value directly into cacheControlValue
  • cacheImmutable always takes preference
  • if you set cacheControl: { immutable: true } we will always write , immutable even cacheImmutable is false

Comment thread test/middleware.test.js
});

describe("should use cacheControl object option (with only immutable: true) when cacheImmutable is false, and not add 'immutable' to Cache-Control header", () => {
describe("should use cacheControl object option (with only immutable: true) when cacheImmutable is false, and add 'immutable' to Cache-Control header", () => {
Copy link
Copy Markdown
Member Author

@alexander-akait alexander-akait Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bjohansebas

We should always write , immutable even if cacheControl is false, developers literally indicated that everything is immutable

@alexander-akait alexander-akait merged commit 063213e into next Jan 27, 2026
14 checks passed
@alexander-akait alexander-akait deleted the refactor-cache-immutable-logic branch January 27, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant