我可以同时拥有.htaccess和:
DEFLATE 在php、图像、html文件等+ php头文件中:
ob_start("gzhandler") ?如果没有,最好的机会是什么?我只是担心它是否会发生冲突。
发布于 2012-12-23 03:25:36
在图像上使用压缩通常是一个非常糟糕的想法,因为大多数在web上广泛使用的图像格式都已经被压缩了,所以你只会给文件增加不必要的开销。您通常希望对文本性质的资源(HTML、CSS、JavaScript等)使用压缩。因为对于那些,压缩比非常高。
至于问题本身,据我所知,不可能同时使用DEFLATE和GZIP,但老实说,因为我从来没有尝试过这样的东西,如果这个信息是不正确的,请原谅我。
至于选择哪一个,我强烈建议你看看下面的帖子,在那里你可以看到DEFLATE和GZIP的一些优缺点。
Why use deflate instead of gzip for text files served by Apache?
我个人在任何可能的情况下都使用DEFLATE,因为有时通过.htaccess实现它比查看代码更容易。我也喜欢在测试或开发东西时快速禁用该功能的可能性。
Apache Server Configs项目有一个非常全面的.htaccess文件,所以您可能想要从中签出该项目。
现在,尽管该文件相当全面,但您可能只需要使用如下所示的正常情况场景配置:
# -----------------------------------------------------------------------
# Defining MIME types to ensure the web server actually knows about them.
# -----------------------------------------------------------------------
<IfModule mod_mime.c>
AddType application/javascript js
AddType application/vnd.ms-fontobject eot
AddType application/x-font-ttf ttf ttc
AddType font/opentype otf
AddType application/x-font-woff woff
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
</Ifmodule>
# -----------------------------------------------------------------------
# Compressing output.
# -----------------------------------------------------------------------
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
AddOutputFilterByType DEFLATE image/x-icon image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
</Ifmodule>https://stackoverflow.com/questions/14005758
复制相似问题