My apache web server admin, claims that,the server supports deflate gzip compression and for reason, shows environment variable HTTP_ACCEPT_ENCODING gzip,deflate to me.

我的apache web服务器管理员声称,服务器支持deflate gzip压缩,并且由于原因,显示环境变量HTTP_ACCEPT_ENCODING gzip,deflate给我。

I know there is two method for compression. method one, is in PHP level, using ob_start('ob_gzhandler') and second method is in server level, using .htaccess with some commands in it, like this one

我知道有两种压缩方法。方法一,在PHP级别,使用ob_start('ob_gzhandler'),第二种方法在服务器级别,使用.htaccess,其中包含一些命令,如下所示

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css

AddOutputFilterByType DEFLATE text / html text / plain text / xml text / css

<FilesMatch "\\.(js|css|html|htm|php|xml)$">

SetOutputFilter DEFLATE

</FilesMatch>

I check both compression method with some tools like page speed

我用一些工具检查压缩方法,如页面速度

First method works for me properly, but second method does not work. I'd like to use server side compression method, and i found many people in the net have problem like me. Server admin just claims everything is ok from his point of view and gzip/deflate is active

第一种方法适合我,但第二种方法不起作用。我想使用服务器端压缩方法,我发现网络中的很多人都有像我这样的问题。服务器管理员只是从他的角度声称一切正常,并且gzip / deflate处于活动状态

I have other problem with leverage browse caching which google recommend web masters to using it.

我还有杠杆浏览缓存的其他问题谷歌推荐网站管理员使用它。

just like compression, there are standard codes for .htaccess file, like this one

就像压缩一样,.htaccess文件有标准代码,就像这个

<IfModule mod_expires.c>

ExpiresActive On

ExpiresByType image/jpg "access 1 year"

ExpiresByType图片/ jpg“访问1年”

ExpiresByType image/jpeg "access 1 year"

ExpiresByType image / jpeg“访问1年”

ExpiresByType image/gif "access 1 year"

ExpiresByType image / gif“access 1 year”

ExpiresByType image/png "access 1 year"

ExpiresByType image / png“访问1年”

ExpiresByType text/css "access 1 month"

ExpiresByType text / css“访问1个月”

ExpiresByType application/pdf "access 1 month"

ExpiresByType application / pdf“access 1 month”

ExpiresByType text/x-javascript "access 1 month"

ExpiresByType text / x-javascript“访问1个月”

ExpiresByType application/x-shockwave-flash "access 1 month"

ExpiresByType应用程序/ x-shockwave-flash“访问1个月”

ExpiresByType image/x-icon "access 1 year"

ExpiresByType image / x-icon“访问1年”

ExpiresDefault "access 2 days"

ExpiresDefault“访问2天”

</IfModule>

unfortunately, it does not work like compression. our apache server version is 2.2.20.

不幸的是,它不像压缩那样工作。我们的apache服务器版本是2.2.20。

I don't know how prove to server admin, which there is something wrong with server installation.

我不知道如何向服务器管理员证明服务器安装有问题。

perhaps it's a bug of this version of apache. i am really confuse, specially when i understand there are some people in the world, which have exactly same problems like me and there is no reply.

也许这是这个版本的apache的错误。我真的很困惑,特别是当我明白世界上有一些人,他们有像我一样的问题而且没有回复。

1 个解决方案

#1


0

One possible explanation: the Apache server may be configured to not allow overrides (i.e., changes in a local .htaccess file). See the Apache AllowOverride docs page to see if that may be the issue here.

一种可能的解释是:Apache服务器可能配置为不允许覆盖(即,本地.htaccess文件中的更改)。请参阅Apache AllowOverride文档页面,了解这可能是问题所在。

In my case my shared web host doesn't have mod_gzip or mod_deflate installed, so I use the same PHP method you mentioned and it works pretty well.

在我的情况下,我的共享Web主机没有安装mod_gzip或mod_deflate,所以我使用你提到的相同的PHP方法,它工作得很好。

I recommend using Curl as a quick method to test both compression and expires settings. (It's also an easy way to share results with your server admin.)

我建议使用Curl作为测试压缩和过期设置的快速方法。 (这也是与服务器管理员分享结果的简便方法。)

For example, to check for compression, include the "--compress" option, and look for a response header "Content-Encoding: gzip":

例如,要检查压缩,请包含“--compress”选项,并查找响应头“Content-Encoding:gzip”:

$ curl --head --compress http://cdn.sstatic.net/stackoverflow/all.css
HTTP/1.1 200 OK
Server: nginx/0.8.36
Date: Wed, 28 Dec 2011 03:15:22 GMT
Content-Type: text/css
Connection: keep-alive
Cache-Control: max-age=604800
Last-Modified: Wed, 28 Dec 2011 00:54:40 GMT
ETag: "0c85c47fbc4cc1:0"
X-Cache: HIT
Content-Encoding: gzip

You can also check for the working Expires header:

您还可以检查工作的Expires标头:

$ curl --head http://l.yimg.com/a/i/us/sp/v/ncaaf/teams/1/80x60/sss3.gif
HTTP/1.1 200 OK
Date: Thu, 22 Dec 2011 01:34:59 GMT
Cache-Control: max-age=315360000
Expires: Sun, 19 Dec 2021 01:34:59 GMT
Last-Modified: Fri, 11 Dec 2009 16:54:28 GMT
Accept-Ranges: bytes
Content-Length: 3059
Content-Type: image/gif
Age: 524606
Connection: keep-alive
Server: YTS/1.20.9

更多相关文章

  1. php 封装原生数据导出的方法
  2. PHP限制HTML内容中图片必须是本站的方法
  3. Windows7搭建Apache本地服务器+PHP环境
  4. php连接mysql的三种方法
  5. 从浏览器中删除发送到服务器的标题。
  6. PHP中使用cURL实现Get和Post请求的方法
  7. 怎么知道php代码运行时调用了那个类、那个方法呢?
  8. php 从指定数字中获取随机组合的方法
  9. php执行shell不阻塞方法

随机推荐

  1. android中fragment和activity之间相互通
  2. Android UI之弹出对话框
  3. 如何在Android上使用OpenGL ES 2.0绘制点
  4. android编程铁定会碰到的问题 adb 出错 F
  5. Android 时间日期选择器的用法
  6. listview 通过筛选全部城市显示出搜索的
  7. Android 自动编译、打包生成apk文件 1 -
  8. 问题记录-Activity跳转后显示空白界面
  9. Android - Espresso -滚动到非列表视图项
  10. demo_代码注册广播接受者_Service