Skip to content
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

fix(perf): join excluded extensions into one regex instead of spreading into multiple regexes #49

Merged
merged 1 commit into from
Aug 25, 2023

Conversation

jasonbarry
Copy link

@jasonbarry jasonbarry commented Aug 24, 2023

This PR simplifies the excludedPaths regexes by joining all of the excluded extensions into a single regex, vs spreading them into multiple. In turns out that joining all into a single regex is much more performant (Slack thread). Closes #46

To test, go to https://deploy-preview-49--csp-nonce.netlify.app, and with a clean/fresh browser cache, inspect the response headers for the document html, and for the 404ing favicon.ico. The document html should have the x-debug-csp-nonce: invoked response header, whereas the favicon.ico resource should not.

You can try this on https://deploy-preview-18839--app.netlify.com too -- only the document html should have x-debug-csp-nonce: invoked, and not any of the other JS/CSS/etc assets.

@netlify
Copy link

netlify bot commented Aug 24, 2023

Deploy Preview for csp-nonce ready!

Name Link
🔨 Latest commit e19161a
🔍 Latest deploy log https://app.netlify.com/sites/csp-nonce/deploys/64e7d5ecb80d3d000898f634
😎 Deploy Preview https://deploy-preview-49--csp-nonce.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@jasonbarry jasonbarry changed the title fix: join excluded extensions into one regex instead of spreading into multiple regexes fix(perf): join excluded extensions into one regex instead of spreading into multiple regexes Aug 24, 2023
@jasonbarry jasonbarry merged commit f053d5a into main Aug 25, 2023
5 checks passed
@jasonbarry jasonbarry deleted the fix/simplify-exclude-regexes branch August 25, 2023 13:38
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.

Simplify regexes of excludedExtensions
2 participants