-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Performance: fix compression issues by adjusting middleware matcher #12954
Conversation
✅ Deploy Preview for ethereumorg ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Lighthouse scores are calculated based on the latest audit results |
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.
Images aren't loading for me on iOS.
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.
@minimalsm @corwintines good catch, there seem to be a few weird things going on with redirects/middleware/trailingslashes with Next 14. Investigating... |
@coderabbitai review |
Actions PerformedReview triggered.
|
WalkthroughThe recent updates to Changes
Recent Review DetailsConfiguration used: CodeRabbit UI Files ignored due to path filters (1)
Files selected for processing (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 0
Out of diff range and nitpick comments (2)
src/middleware.ts (2)
24-36
: The matcher configuration looks correct and should effectively exclude the specified paths from middleware processing.Consider adding more detailed comments to explain why each path is excluded, which could help future maintainers understand the context better.
Line range hint
41-63
: The updates to the middleware function improve the handling of static files and locale redirection.Consider adding error handling for cases where
detectLocale
might fail to detect a valid locale, to ensure robustness.
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.
Working for me now, LGTM
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.
LGTM now :)
Images fixes, and seeing br encoding on js and css files.
Our current implementation has odd behavior when serving static files that are compressed. Depending on the browser, it will serve files using
gzip
orbr
, since the same browsers support both algorithms (same req header in all these browsers:Accept-Encoding: gzip, deflate, br, zstd
).We would like to always serve the
br
version as it is much lighter than thegzip
version. For example, the_app.js
bundle size drops from ~330kb to ~215kb when using Brotli.The issue is related to the custom middleware we use to redirect requests to different locales. Currently, we process all incoming requests (which is not necessary) and for some reason this seems to cause a conflict with the netlify server which ends up serving
gzip
files instead.Description
This PR adds a custom
matcher
to the exported middleware config to only process the matched paths and ignore the rest.Summary by CodeRabbit