Cache bundle assets for slow network connections#1195
Cache bundle assets for slow network connections#1195hwanseoc wants to merge 2 commits intopingdotgg:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can disable poems in the walkthrough.Disable the |
There was a problem hiding this comment.
Pull request overview
Adds aggressive caching headers for Vite-built static assets served by the server to improve reload performance on slow networks.
Changes:
- Set
Cache-Control: public, max-age=31536000, immutablefor static files under/assets/*. - Refactor static-file response code to build a headers object before responding.
- Add a server test asserting the cache header is present for
/assets/...requests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/server/src/wsServer.ts | Adds conditional Cache-Control header when serving static files under the assets/ prefix. |
| apps/server/src/wsServer.test.ts | Adds a test ensuring /assets/* responses include the immutable cache header. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
What Changed
This adds long-lived cache headers for built files served from
/assets/*./assets/*getsCache-Control: public, max-age=31536000, immutableWhy
The entire JS/CSS payload is about 3 MB, which on a slow connection means a page load can take more than 10 seconds on every reload.
The cached files are this scoped to
/assets/*only. These files are Vite build outputs with content-hashed filenames, so I expect them to be safe to cache aggressively even for development.UI Changes
No UI or interaction change.
Checklist
Note
Cache static bundle assets with immutable
Cache-Controlheaders for slow network connectionsAdds
Cache-Control: public, max-age=31536000, immutableto HTTP responses for files served under theassets/path in wsServer.ts. Files outsideassets/continue to be served without cache headers. A test is added to verify the header is present for hashed asset filenames.Macroscope summarized c40dd7e.