gpt4 book ai didi

.htaccess - Chrome Devtool 不在响应 header 中显示 Content-Encoding

转载 作者:行者123 更新时间:2023-12-04 15:10:38 25 4
gpt4 key购买 nike

我启用 gzip 压缩以提高 Google PageSpeed Insights 的速度:

如果压缩 mantaspersonalizadas.com/fonts/Cocktail-Shaker.svg,将节省 144.1 KB(减少 65%)。
如果压缩 mantaspersonalizadas.com/fonts/Cocktail-Shaker.ttf,将节省 62.6 KB(减少 49%)。
如果压缩 mantaspersonalizadas.com/fonts/Cocktail-Shaker.woff,将节省 2.6 KB(减少 5%)。

我使用 Apache 服务器,我将此代码添加到 .htacess:

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/opentype

# For Olders Browsers Which Can't Handle Compression
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

如何检查我的本地服务器中是否启用了放气?

Chrome DevTools 不显示 Content-Enconding:
enter image description here

最佳答案

让我们来测试一下。

Chrome 对 example.com 的请求(包含 gzip):

GET / HTTP/1.1
Host: www.example.com
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
If-None-Match: "359670651"
If-Modified-Since: Fri, 09 Aug 2013 23:54:35 GMT

来自 example.com 的 Chrome 响应(不包含 gzip):
HTTP/1.1 304 Not Modified
Accept-Ranges: bytes
Cache-Control: max-age=604800
Date: Thu, 08 Dec 2016 14:06:04 GMT
Etag: "359670651"
Expires: Thu, 15 Dec 2016 14:06:04 GMT
Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT
Server: ECS (iad/182A)
Vary: Accept-Encoding
X-Cache: HIT

Curl 请求(克隆 Chrome 请求,包含 gzip):
curl -I
-H "GET / HTTP/1.1"
-H "Host: www.example.com"
-H "Connection: keep-alive"
-H "Cache-Control: max-age=0"
-H "Upgrade-Insecure-Requests: 1"
-H "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36"
-H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
-H "Accept-Encoding: gzip, deflate, sdch"
-H "Accept-Language: en-US,en;q=0.8"
-H "If-None-Match: "359670651""
-H "If-Modified-Since: Fri, 09 Aug 2013 23:54:35 GMT"
example.com

curl 响应(包含 gzip):
HTTP/1.1 200 OK
Content-Encoding: gzip
Accept-Ranges: bytes
Cache-Control: max-age=604800
Content-Type: text/html
Date: Thu, 08 Dec 2016 14:18:34 GMT
Etag: "359670651"
Expires: Thu, 15 Dec 2016 14:18:34 GMT
Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT
Server: ECS (iad/182A)
X-Cache: HIT
x-ec-custom-error: 1
Content-Length: 606

结论

Chrome 目前不显示内容编码。火狐也不行。我不知道为什么。

现在我知道他们没有向我展示所有内容,我再也不会相信响应头信息了。

一路 curl 。

关于.htaccess - Chrome Devtool 不在响应 header 中显示 Content-Encoding,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28498618/

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