2014-01-13 144 views
1

由於YSlow仍然建議在我的網站http://www.donboscoeltern.de上啓用壓縮功能,我試圖通過在.htaccess文件中包含以下代碼片段(以下列出的是最後3個版本):無法啓用壓縮(deflate/gzip)


# 1 
<ifModule mod_gzip.c> 
mod_gzip_on Yes 
mod_gzip_dechunk Yes 
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$ 
mod_gzip_item_include handler ^cgi-script$ 
mod_gzip_item_include mime ^text/.* 
mod_gzip_item_include mime ^application/x-javascript.* 
mod_gzip_item_exclude mime ^image/.* 
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* 
</ifModule> 

# 2 
# compress text, HTML, JavaScript, CSS, and XML 
AddOutputFilterByType DEFLATE text/plain 
AddOutputFilterByType DEFLATE text/html 
AddOutputFilterByType DEFLATE text/xml 
AddOutputFilterByType DEFLATE text/css 
AddOutputFilterByType DEFLATE application/xml 
AddOutputFilterByType DEFLATE application/xhtml+xml 
AddOutputFilterByType DEFLATE application/rss+xml 
AddOutputFilterByType DEFLATE application/javascript 
AddOutputFilterByType DEFLATE application/x-javascript 

# remove browser bugs 
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 

# 3 
<ifmodule mod_deflate.c> 
# Insert filter 
SetOutputFilter DEFLATE 

# 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 

# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48 
# the above regex won't work. You can use the following 
# workaround to get the desired effect: 
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html 

# Don't compress images 
SetEnvIfNoCase Request_URI \ 
\.(?:gif|jpe?g|png)$ no-gzip dont-vary 

# Make sure proxies don't deliver the wrong content 
Header append Vary User-Agent env=!dont-vary 
</ifmodule> 

以上任何版本都不會導致任何更改:使用gtmetrix等的測試都表示網站http://www.donboscoeltern.de仍未壓縮。

你有什麼想法嗎?
謝謝!

問候,
弗拉德Ghitulescu

+0

也許你的主機是防止(或重寫)你的一些HTTP頭。 – cubitouch

+0

我已經和我的託管公司談過了,他們正在這樣做:mod_gzip關閉了入門級主機(這是我對這個只有1頁的網站所擁有的)。我還沒有回答關於mod_deflate的問題,但是... – user3191981

+0

當你解決(或發現)你需要了解你的問題時,請記得寫下你的問題的答案;) – cubitouch

回答

1

的原因奇怪的行爲 - 沒有反應在所有關於通過的.htaccess文件壓縮不同的方法 - 是託管公司:他們關掉了mod_gzip的模塊爲入門級主機(我有)。他們的解決方案:購買下一個級別!

感謝您的提示,cubitouch!

親切的問候, 弗拉德