feat: suppress caching for added project hosts via Cache-Control override#798
Closed
davidnuescheler wants to merge 7 commits intomainfrom
Closed
feat: suppress caching for added project hosts via Cache-Control override#798davidnuescheler wants to merge 7 commits intomainfrom
davidnuescheler wants to merge 7 commits intomainfrom
Conversation
…ride - Add declarativeNetRequest rules that set response header Cache-Control: max-age=60 for all added project hosts (prod, preview, live, review) - Overrides server Cache-Control for HTML (main_frame, sub_frame) and JSON (xmlhttprequest) to 1 minute - Re-apply header config when project is added or updated
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
rofe
requested changes
Feb 25, 2026
Contributor
rofe
left a comment
There was a problem hiding this comment.
Please also add test cases for getHostDomains() and getCacheControlRules().
rofe
requested changes
Feb 26, 2026
rofe
reviewed
Feb 26, 2026
rofe
requested changes
Feb 27, 2026
src/extension/auth.js
Outdated
Comment on lines
49
to
52
| p?.host, | ||
| p?.previewHost, | ||
| p?.liveHost, | ||
| p?.reviewHost, |
Contributor
There was a problem hiding this comment.
Turns out we only need rules for host and liveHost. previewHost and reviewHost already have the 60s cache TTL:
Suggested change
| p?.host, | |
| p?.previewHost, | |
| p?.liveHost, | |
| p?.reviewHost, | |
| p?.host, | |
| p?.liveHost, |
src/extension/auth.js
Outdated
| responseHeaders: [{ | ||
| header: 'Cache-Control', | ||
| operation: 'set', | ||
| value: `max-age=${CACHE_MAX_AGE_SECONDS}`, |
Contributor
There was a problem hiding this comment.
Let's keep the must-revalidate
Suggested change
| value: `max-age=${CACHE_MAX_AGE_SECONDS}`, | |
| value: `max-age=${CACHE_MAX_AGE_SECONDS}, must-revalidate`, |
src/extension/auth.js
Outdated
Comment on lines
73
to
81
| 'main_frame', | ||
| 'sub_frame', | ||
| 'script', | ||
| 'stylesheet', | ||
| 'image', | ||
| 'xmlhttprequest', | ||
| 'media', | ||
| 'font', | ||
| 'other', |
Contributor
There was a problem hiding this comment.
We actually don't need image, media and other
Suggested change
| 'main_frame', | |
| 'sub_frame', | |
| 'script', | |
| 'stylesheet', | |
| 'image', | |
| 'xmlhttprequest', | |
| 'media', | |
| 'font', | |
| 'other', | |
| 'main_frame', | |
| 'sub_frame', | |
| 'script', | |
| 'stylesheet', | |
| 'xmlhttprequest', | |
| 'font', |
test/auth.test.js
Outdated
| const rules = getCacheControlRules(configs); | ||
| expect(rules).to.have.lengthOf(3); | ||
| expect(rules.every((r) => r.action?.responseHeaders?.[0]?.header === 'Cache-Control')).to.be.true; | ||
| expect(rules.every((r) => r.action.responseHeaders[0].value === `max-age=${CACHE_MAX_AGE_SECONDS}`)).to.be.true; |
Contributor
There was a problem hiding this comment.
Suggested change
| expect(rules.every((r) => r.action.responseHeaders[0].value === `max-age=${CACHE_MAX_AGE_SECONDS}`)).to.be.true; | |
| expect(rules.every((r) => r.action.responseHeaders[0].value === `max-age=${CACHE_MAX_AGE_SECONDS}, must-revalidate`)).to.be.true; |
src/extension/auth.js
Outdated
| const { host: adminHost } = new URL(ADMIN_ORIGIN); | ||
| const { host: newAdminHost } = new URL(ADMIN_ORIGIN_NEW); | ||
|
|
||
| /** Cache-Control max-age in seconds for added project hosts (HTML/JSON). 60 = 1 minute. */ |
Contributor
There was a problem hiding this comment.
Suggested change
| /** Cache-Control max-age in seconds for added project hosts (HTML/JSON). 60 = 1 minute. */ | |
| /** Cache-Control max-age in seconds for added project hosts (HTML, JSON and code): 1 minute. */ |
…es, @ts-ignore replaceAll Made-with: Cursor
Contributor
|
Doesn't work as expected, Chrome ignores cache instructions for fetch requests. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Suppresses caching for added project hosts (especially prod) by overriding response headers via the extension's declarativeNetRequest rules.
Cache-Control: max-age=60(1 minute), overriding the server's HTML/JSON cache headers.main_frame,sub_frame,xmlhttprequest, andother(covers HTML and JSON).CACHE_MAX_AGE_SECONDS(default 60) is exported fromauth.jsfor easy tuning.