【发布时间】:2017-05-04 11:06:50
【问题描述】:
我现在所拥有的。
在 httpd-deflate.conf 的 Location 部分:
SetEnvIfNoCase Request_URI \
\\.(?:gif|jpe?g|jpg|png|rar|zip|exe|flv|swf|mov|wma|mp3|mp4|avi|mp?g)$ no-gzip dont-vary
在 .htaccess 中:
Options +FollowSymlinks
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index\.php$ [NC]
RewriteRule ^(.+)$ /index.php?_route_=$1 [L,QSA]
通过这些设置,实际在服务器上的图像会根据需要进行处理 - 没有 gzip 编码,并且在服务器响应中没有“Content-Encoding: gzip”标头。
但是在 index.php 文件中处理了不存在的图像。 http://example.com/nonexistent-path/non-existent-image.jpg 响应正文:
Cache-Control: max-age=84148768
Connection: keep-alive
Content-Encoding: gzip
Content-Length: 49860
Content-Type: image/jpeg - ((I set it in php manually after image generation before output))
Date: Mon, 01 May 2017 22:04:48 GMT
Expires: Tue, 31 Dec 2019 20:44:16 GMT
Last-Modified: Thu, 17 Nov 2016 14:51:10 GMT
Server: nginx
Strict-Transport-Security: max-age=2592000
Vary: Accept-Encoding
X-XSS-Protection: 1; mode=block
x-content-type-options nosniff
正如您所见,这个不存在的图像被处理为文档,而不是 .jpg 图像。
据我了解,在服务器上我有 Apache 和 nginx 代理。我应该在 httpd-deflate.conf 或任何其他位置粘贴什么来删除不存在图像的 gzip 编码并删除服务器响应中的“Content-Encoding: gzip”?
谢谢。
【问题讨论】:
标签: apache .htaccess nginx gzip mod-deflate