Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess Chrome Devtool不会在响应头中显示内容编码_.htaccess_Google Chrome_Pagespeed_Mod Deflate - Fatal编程技术网

.htaccess Chrome Devtool不会在响应头中显示内容编码

.htaccess Chrome Devtool不会在响应头中显示内容编码,.htaccess,google-chrome,pagespeed,mod-deflate,.htaccess,Google Chrome,Pagespeed,Mod Deflate,我正在启用gzip压缩以提高Google PageSpeed Insights的速度: 如果压缩mantaspersonalizadas.com/fonts/cockbox-Shaker.svg,将节省144.1 KB(减少65%)。 如果压缩mantaspersonalizadas.com/fonts/cockbox-Shaker.ttf,将节省62.6KB(减少49%)。 如果压缩mantaspersonalizadas.com/fonts/cockbox-Shaker.woff,将节省2.

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

如果压缩mantaspersonalizadas.com/fonts/cockbox-Shaker.svg,将节省144.1 KB(减少65%)。 如果压缩mantaspersonalizadas.com/fonts/cockbox-Shaker.ttf,将节省62.6KB(减少49%)。 如果压缩mantaspersonalizadas.com/fonts/cockbox-Shaker.woff,将节省2.6KB(减少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>

AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType泄气文本/普通
AddOutputFilterByType放气图像/x图标
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE应用程序/rss+xml
AddOutputFilterByType DEFLATE应用程序/javascript
AddOutputFilterByType DEFLATE应用程序/x-javascript
AddOutputFilterByType DEFLATE应用程序/xml
AddOutputFilterByType DEFLATE应用程序/xhtml+xml
AddOutputFilterByType放气应用程序/x-font
AddOutputFilterByType放气应用程序/x-font-truetype
AddOutputFilterByType放气应用程序/x-font-ttf
AddOutputFilterByType放气应用程序/x-font-otf
AddOutputFilterByType放气应用程序/x-font-opentype
AddOutputFilterByType DEFLATE应用程序/vnd.ms-fontobject
AddOutputFilterByType DEFLATE字体/ttf
AddOutputFilterByType DEFLATE字体/otf
AddOutputFilterByType泄气字体/opentype
#对于不能处理压缩的旧浏览器
浏览器匹配^Mozilla/4 gzip纯文本/html
浏览器匹配^Mozilla/4\.0[678]无gzip
BrowserMatch\bMSIE!没有gzip!仅限gzip文本/html
如何检查本地服务器中是否启用了deflate?

Chrome开发工具不显示内容编码:

Chrome浏览器似乎出现了问题,我也遇到了同样的问题,虽然deflate在服务器上不起作用,但后来我尝试了Firefox并使用了firebug,它正确地显示了标题中的内容编码


此外,Chrome中下载的文件大小没有显示未压缩的文件大小,而Firefox显示了正确的压缩文件大小。

让我们来测试一下

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
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 -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
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
example.com的Chrome响应(不包含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
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 -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
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
Curl请求(Chrome请求的克隆,包含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
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 -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
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
Curl响应(包含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
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 -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
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当前未显示内容编码。Firefox也不例外。我不知道为什么

现在我知道他们并没有向我展示所有信息,我再也不相信任何一个响应头信息了

一路卷曲。

As@Jay

Chrome当前未显示内容编码。Firefox也不例外。我不知道为什么

截至2018年12月,Chrome和Firefox都出现了相同的行为,Firebug也消失了

为我做的是,在响应标题部分([F12]->网络选项卡->选择资源->标题选项卡)中显示正确的内容编码


我在弄乱了我的生产服务器两个小时后偶然发现了这一点!我可以确认,截至2017年10月,Chrome+Firefox甚至没有在DevTools中显示主页的压缩线程器,但它们会显示其他所有资源(例如CSS、JS甚至Ajax加载页面)。看这里:提议的卷曲技巧对我来说是可靠的。