-
Notifications
You must be signed in to change notification settings - Fork 121
Frontend: compress most files to .gz #3771
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
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds gzip pre-compression of selected frontend build assets via Vite and configures nginx to always serve these .gz files from /assets, removing the need for try_files and the original uncompressed assets. Sequence diagram for serving pre-compressed frontend assetssequenceDiagram
participant Browser
participant Nginx
participant FrontendAssets as Frontend_assets_directory
Browser->>Nginx: GET /assets/app.js
Nginx->>FrontendAssets: Lookup app.js.gz (gzip_static always)
alt app.js.gz exists
Nginx-->>Browser: 200 app.js.gz
Browser->>Browser: Decompress gzip and execute JS
else app.js.gz missing or client no gzip
Nginx-->>Browser: 404 or fallback response
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've left some high level feedback:
- Using
deleteOriginFile: truemeans only.gzassets will be deployed; consider whether any non-gzip-capable clients, tooling, or direct file access (e.g. via S3/bucket browsing or other servers) rely on the original files and whether it’s safer to keep them. - Removing
try_files $uri $uri/;from the/assets/location changes how missing or directory requests are handled; confirm that you don’t rely on any fallback behavior there (e.g. serving a default file or index) and that 404 handling remains as intended.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Using `deleteOriginFile: true` means only `.gz` assets will be deployed; consider whether any non-gzip-capable clients, tooling, or direct file access (e.g. via S3/bucket browsing or other servers) rely on the original files and whether it’s safer to keep them.
- Removing `try_files $uri $uri/;` from the `/assets/` location changes how missing or directory requests are handled; confirm that you don’t rely on any fallback behavior there (e.g. serving a default file or index) and that 404 handling remains as intended.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This saves about 75mb of image size
900902e to
a27353a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've left some high level feedback:
- Using
viteCompressionwithdeleteOriginFile: truemeans the build output only contains.gzversions of the filtered assets; consider keeping originals (or limiting this to assets you know are only fetched via nginx withAccept-Encoding: gzip) to avoid breaking any non-gzip consumers or tooling that expects raw files. - Enabling
gzip_static always;in nginx will serve.gzfiles even when the client does not sendAccept-Encoding: gzip; consider usinggzip_static on;instead (or a more targeted location block) to avoid corrupt responses for clients or intermediaries that cannot handle gzip-encoded content.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Using `viteCompression` with `deleteOriginFile: true` means the build output only contains `.gz` versions of the filtered assets; consider keeping originals (or limiting this to assets you know are only fetched via nginx with `Accept-Encoding: gzip`) to avoid breaking any non-gzip consumers or tooling that expects raw files.
- Enabling `gzip_static always;` in nginx will serve `.gz` files even when the client does not send `Accept-Encoding: gzip`; consider using `gzip_static on;` instead (or a more targeted location block) to avoid corrupt responses for clients or intermediaries that cannot handle gzip-encoded content.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This saves about 75mb of image size
Summary by Sourcery
Enable pre-compressed gzip asset delivery in the frontend build and nginx configuration.
New Features:
Enhancements:
Build:
Deployment: