简体   繁体   English

gzip压缩已启用但不起作用

[英]gzip compression is enabled but not working

I have checked gzip compression in the following site http://www.whatsmyip.org/http-compression-test it shows 我已经在以下网站http://www.whatsmyip.org/http-compression-test中检查了gzip压缩

https://domain.com/ is Compressed
Uncompressed Page Size: 108.1 KB
Compressed Page Size: 22.9 KB
Savings: 78.8%

But http://gtmetrix.com/ says 但是http://gtmetrix.com/

There are 25 plain text components that should be sent compressed, any idea 有25个纯文本组件应压缩后发送,任何想法

Without seeing the actual webpage this is just guessing, but most likely the webserver is configured to serve HTML pages with GZIP compression but it's not configured to send other types with GZIP compression. 在没有看到实际网页的情况下,这只是猜测,但是很可能将Web服务器配置为使用GZIP压缩来提供HTML页面,但未配置为使用GZIP压缩来发送其他类型。

When configuring GZIP compression in webservers, you want to make sure that all types that are not already compressed by it's file format have GZIP compression enabled. 在Web服务器中配置GZIP压缩时,您要确保未通过其文件格式压缩的所有类型都启用了GZIP压缩。

This means you want to enable GZIP compression for all text based responses: html, but also css, javascript, json, XML files, rss, etc. But also some non-text files like favicon ico files and most web font-face files(except woff) 这意味着您要为所有基于文本的响应启用GZIP压缩:html,还包括css,javascript,json,XML文件,rss等。还需要一些非文本文件,例如favicon ico文件和大多数Web字体文件(除了woff)

You must not enable GZIP compression for files that are already compressed by their file format. 您不得为已按其文件格式压缩的文件启用GZIP压缩。 That means most images, videos and audio. 这意味着大多数图像,视频和音频。

For an example you can check out the htaccess of the html5 boilerplate project . 例如,您可以检查html5样板项目htaccess

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM