gpt4 book ai didi

java - 在 Apache Tomcat 8 中对图像和字体进行 Gzip 压缩

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:10:54 24 4
gpt4 key购买 nike

这是 Apache Tomcat 8gzip 压缩的配置

<Connector port="7070" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"
compression="on"
compressionMinSize="256"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml,text/plain,text/css,application/javascript,font/otf,font/woff,
font/woff2,image/gif,image/jpg,image/png"/>

png 图片可以。它不适用于 jpg 图像和 woff2 字体,如下所示。

我已经试过了,还是不行

image/jpg <or> image/jpeg <or> application/octet-stream

font/woff <or> font/woff2 <or> application/font-woff <or> application/font-woff2

从 Chrome 测试

enter image description here

最佳答案

您正在尝试压缩已压缩的文件 (gzip),如 woff/woff2、jpg 等。在我看来,这只是资源浪费。并非每种类型的文件都可以压缩(请参阅:Fastly blog about gzip settings)。

以下是 FaSTLy 建议默认压缩的类型:

Extensions: js css html json ico eot otf ttf

Content Types: text/html application/x-javascript text/css application/javascript text/javascript text/plain text/xml application/json application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype application/x-font-ttf application/xml font/eot font/opentype font/otf image/svg+xml image/vnd.microsoft.icon

关于java - 在 Apache Tomcat 8 中对图像和字体进行 Gzip 压缩,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45299418/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com