小编Ox3*_*Ox3的帖子

Apache + Php-FPM + APC:mode_deflate 不压缩 HTML 输出

我准备了一个服务器来运行一个 Magento 实例:Apache + Php-FPM + APC

我遇到的问题是 Apache 没有压缩 Magento PHP 脚本的 HTML 输出。

在我的 .htaccess 我有:

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml
AddOutputFilterByType DEFLATE application/javascript application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
Run Code Online (Sandbox Code Playgroud)

我还尝试使用以下方法压缩所有内容:

SetOutputFilter DEFLATE
Run Code Online (Sandbox Code Playgroud)

但我没有运气。

Zlib 压缩被禁用:

php_flag zlib.output_compression on
Run Code Online (Sandbox Code Playgroud)

我的猜测是这与 Php-FPM 或 APC 有关系,但我不确定问题是什么。

为未压缩页面返回的 MIME 类型是:

Content-Type: text/html; charset=UTF-8
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

更新:问题似乎与 PHP 处理的任何内容有关,如果我将 html 输出复制到 .html 文件然后获取它,它将被压缩,如果我将同一文件重命名为 .php 并将其获取输出不会被压缩。以下是标题:

[[响应标题 HTML 文件]]

Date Fri, 29 Aug 2014 20:03:13 GMT
Content-Encoding gzip …
Run Code Online (Sandbox Code Playgroud)

php-fpm mod-deflate apache-2.2 alternative-php-cache

5
推荐指数
0
解决办法
1416
查看次数