.htaccess 无法启用压缩(放气/gzip)

.htaccess 无法启用压缩(放气/gzip),.htaccess,compression,gzip,deflate,.htaccess,Compression,Gzip,Deflate,由于YSlow仍然建议在我的站点上启用压缩,因此我尝试在.htaccess文件中包含以下代码片段(下面列出的是最后3个版本): #3 #插入过滤器 SetOutputFilter放气 #Netscape 4.x有一些问题。。。 浏览器匹配^Mozilla/4 gzip纯文本/html #网景4.06-4.08还有一些问题 浏览器匹配^Mozilla/4\.0[678]无gzip #MSIE伪装成网景,但它很好 #BrowserMatch\bMSIE!没有gzip!仅限gzip文本/html

由于YSlow仍然建议在我的站点上启用压缩,因此我尝试在.htaccess文件中包含以下代码片段(下面列出的是最后3个版本):



#3
#插入过滤器
SetOutputFilter放气
#Netscape 4.x有一些问题。。。
浏览器匹配^Mozilla/4 gzip纯文本/html
#网景4.06-4.08还有一些问题
浏览器匹配^Mozilla/4\.0[678]无gzip
#MSIE伪装成网景,但它很好
#BrowserMatch\bMSIE!没有gzip!仅限gzip文本/html
#注意:由于Apache 2.0.48之前的mod_setenif中存在错误
#上面的正则表达式不起作用。您可以使用以下命令
#获得所需效果的变通方法:
浏览器匹配\bMSI[E]!没有gzip!仅限gzip文本/html
#不要压缩图像
setEnvifLocase请求\u URI\
\(?:gif | jpe | g | png)$无gzip不变
#确保代理不会提供错误的内容
标头附加变量用户代理env=!不要改变

以上版本都没有引起任何变化:使用gtmetrix等进行的测试都表明该站点仍然没有被压缩

你有什么想法吗?
谢谢大家!

问候,

Vlad Ghitlescu

这种奇怪行为的原因是托管公司:他们关闭了入门级托管的mod_gzip-module(我已经关闭了)。他们的解决方案:购买下一级

谢谢你的提示,cubitouch

亲切问候,,
Vlad

也许你的主机正在阻止(或重写)你的一些HTTP头。我已经和我的主机公司谈过了,他们正在这样做:mod_gzip在入门级主机上被关闭(这就是我在这个仅1页的站点上所做的)。关于mod_deflate,我还没有答案……记住,当你解决(或找到)所有你需要了解的问题时,要写一个问题的答案;)我刚刚做了。再次感谢!
# 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>