apache - 为什么 Gzip 压缩我的 css & javascript 而不是我的 HTML/php?

标签 apache gzip

当我查看这个网站时:http://www.tropicbreeze.co.uk/ ,例如 http://checkgzipcompression.com/ - 它报告它正在使用 Gzip。但伊斯洛不同意。

我的 .htaccess 文件中有这个:

AddOutputFilterByType DEFLATE text/html text/php text/x-php application/php  application/x-php  application/x-httpd-php-source text/plain text/xml text/css text/javascript application/x-javascript application/xhtml+xml application/javascript application/x-httpd-php

在 Firebug 的 Net 选项卡中检查标题,我可以看到该页面上各种关联的 .css 和 .js 文件具有按预期显示的 Content-Encoding gzip - 但 php 文件没有。

Yslow 告诉我主页没有使用 Gzip。 Firebug Net 选项卡表示主页(和服务器上的其他 php 文件)未使用 Content-Encoding gzip 发送

我已经尝试添加我能找到的所有建议的 mimetype 过滤器,据我所知,DEFLATE text/html 无论如何都应该覆盖它,但仍然没有乐趣。

我已经清除了我的缓存并且没有使用代理。

谁能建议我错过了什么?为什么 php 文件没有被 gzip 其他文件压缩?或者,如果它们被 gzip 压缩,为什么 Firebug/yslow 认为它们不是?

最佳答案

不确定到底是什么问题,但也许一个简单的解决方法是尝试类似的东西......

<IfModule mod_deflate.c>
    <FilesMatch "\.(css|htm|html|js|php|txt|xml)$">
        SetOutputFilter DEFLATE
    </FilesMatch>
</IfModule>

...应该在流行的文件扩展名(包括 PHP)上设置压缩。

我个人认为这种格式对人类来说也更容易阅读。奖金!

关于apache - 为什么 Gzip 压缩我的 css & javascript 而不是我的 HTML/php?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18634528/

相关文章:

apache - ProxyPassMatch 与 ProxyPassReverse

apache - Apache 配置文件 : 中的 XAMPP PORT 80 是 Busy/EasyPHP 错误

PHP GZip 和服务器发送的事件流

python - Apache2.2:ImportError: 没有名为 site 的模块

apache - httpd-2.4.16 包中的 httpd.conf 文件在哪里?

java - 在 proxypassreverse 设置中从 url 中删除应用程序名称

Python从gzip压缩文件中读取csv行

linux - 如何在使用 tar 压缩目录时排除大文件

compression - 多部分 gzip 文件随机访问(在 Java 中)

IIS + compression-webpack-plugin (gzip) - 使用源代码加载 "script"失败