-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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: don't compress already compressed fonts #6432
Conversation
modules/caddyhttp/encode/encode.go
Outdated
"font/*", | ||
"font/ttf*", | ||
"font/otf*", | ||
"font/x-woff*", |
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.
This line isn't needed, WOFF is pre-compressed
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.
According to https://community.cloudflare.com/t/cloudflare-is-missing-the-current-woff-media-type-in-the-default-compression-config/679095, this is beneficial if Brotli (and I guess Zstandard) are used.
Brotli isn't natively supported by Caddy, but FrankenPHP and https://github.com/dunglas/caddy-cbrotli allow us to easily add support for it. Zstandard is supported and is now on by default for Chrome and Firefox (not for Safari).
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.
Fair enough, but if WOFF1 is to be compressed then the matcher should be the standardized font/woff
instead of or in addition to miscellaneous names it went by before being standardized.
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.
TBH, I just copied the list maintained by Cloudflare: https://developers.cloudflare.com/speed/optimization/content/brotli/content-compression/#compression-between-cloudflare-and-website-visitors
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.
Also won't that wildcard on the end cause it to match WOFF2 anyway? AFAICT that wildcard is there in case the server appends a charset to the content type, but these are binary formats so that shouldn't happen.
For a second opinion, AWS and GCP don't compress either version of WOFF:
https://cloud.google.com/cdn/docs/dynamic-compression#compressible-content
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.
That's true; I am not sure what would come after the media/type
for binary types, and we could probably remove the wildcards (but that doesn't have to happen in this PR).
So we don't "woff
le" over this too much longer (hehe), maybe let's remove woff for now, since even the 1.0 was also compressed. I know that article linked by @dunglas recommends compressing woff too because of "additional savings" possible at the edge, but IMO that would be quite minimal and still expensive for marginal gains.
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.
The MIME type of WOFF2 font/woff2
, so it will not match, but I can remove this MIME type if you want.
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.
WOFF removed
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.
Thanks; hopefully that's the best decision, but I'm not really sure, but it sounds like there is no real consensus anyway. Both WOFF versions are compressed, even if WOFF2 has "better" compression; but I don't see a need to compress either of them.
Appreciate it!
Fixes a regression introduced in #6081.
Closes #6428.