<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html #<<facebook share problem
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</IfModule>
我在.htaccess中激活mod_deflate [AddOutputFilterByType DEFLATE text / html]时遇到问题 分享按钮有效,但没有标题,没有缩略图,没有描述.... 我尝试并禁用它,共享很顺利,但我真的需要DEFLATE text / html。
答案 0 :(得分:0)
您是否只在.htaccess中配置mod_deflate? httpd.conf中还有其他mod_deflate参数吗?
我建议您确保使用的所有格式都正确无误。另外,尝试简单的参数。首先仅使用AddOutputFilterByType DEFLATE text/html
进行测试。然后,去其他格式。在测试之前,启用mod_deflate日志。
下面我给我测试了一个示例Apache 2.2.x httpd.conf。在其中,您可以看到如何配置deflate日志:
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
# example of how to compress ONLY html, plain text and xml #
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css text/javascript application/javascript
# Don't compress binaries
SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|iso|tar|bz2|sit|rar) no-gzip dont-vary
# Don't compress images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|jpg|ico|png) no-gzip dont-vary
# Don't compress PDFs
SetEnvIfNoCase Request_URI .pdf no-gzip dont-vary
# Don't compress flash files (only relevant if you host your own videos)
SetEnvIfNoCase Request_URI .flv no-gzip dont-vary
# Netscape 4.X has some problems
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
# Setup custom deflate log
DeflateFilterNote Input instr
DeflateFilterNote Output outstr
DeflateFilterNote Ratio ratio
LogFormat '"%r" %{outstr}n/%{instr}n %{ratio}n%%' DEFLATE
CustomLog logs/deflate_log DEFLATE
我从这个网站获得的这个示例:How To: Optimize Your Apache Site with Mod Deflate