2014-10-19 58 views
0
<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> 

我有一個問題,當我啓動mod_deflate模塊[AddOutputFilterByType DEFLATE text/html的]在.htaccess 共享按鈕的作品,但沒有標題,沒有縮略圖,沒有說明.... 我想和殘疾人吧,共享很好,但我真的需要DEFLATE文本/ HTML。帶Facebook分享按鈕的mod_deflate未顯示共享詳細信息?

回答

0

您是否只在.htaccess中配置mod_deflate? httpd.conf中有其他mod_deflate參數嗎?

我建議你確保使用的所有格式都是正確的。另外,嘗試簡單的參數。首先僅使用AddOutputFilterByType DEFLATE text/html進行測試。然後,去其他格式。在測試之前,啓用mod_deflate日誌。

下面我放了一個我測試過的Apache 2.2.x httpd.conf的示例。在這裏面你可以看到如何配置放氣日誌:

<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