查看所有包含 apache 标签的文章
七月
27

配置Apache2启用mod_expires模块给文件添加Expires头

Author Dominic    Category Web应用     Tags , ,

使用YSlow发现所在服务器上传输出来的文件头都置为: Thu, 19 Nov 1981 08:52:00 GMT了,非常奇怪的一个时间(莫非或者php某个开发人员是这个时候出生的),YSlow给出了加载模块的建议。

加载模块之后,编辑httpd.conf加入如下配置:

# enable expirations
ExpiresActive On
# expire GIF images after a day from the time they were accessed
ExpiresByType image/gif image/jpg A86400
# HTML documents are good for a hour from the  the time they were accessed
ExpiresByType text/html M3600
# expire all default from the time they were accessed
ExpiresDefault “A7200″

七月
27

配置Apache2启用deflate压缩加快传输

Author Dominic    Category Web应用     Tags ,

今天下载了Yahoo的给Firefox开发的YSlow插件,这个插件确实不错,能够给出不少优化建议,发现所在主机没有开启压缩。

首先加载mod_deflate。

在httpd.conf中加入

<Location />

# Insert filter
SetOutputFilter

# 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 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|exe|bmp|mp3|rar|zip|swf|cab|t?gz|bz2|sit)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary

# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary

</Location>

再重启即可,/etc/init.d/apache2 restart

经过port80software的在线检测,首页大小从91977 bytes压缩到13376 bytes,传输速度提高6.8X,传输速度从原来12.832 s缩减到1.866 s。

如果修改配置之后提示“Invalid command ‘Header’, perhaps mis-spelled or defined by a module not included in the server configuration”,则加载Header模块即可,不过最好还是在编译模块时直接加上–enable- –enable-headers就省事多了。

专题推荐

标签

404错误 apache article CSS dotNet fckeditor Hack iOS iTouch javascript PayPal PHP rar ubuntu utf8 VMware VMware Tools weblinks Win2008 Windows Server 2008 Wordpress xajax XOOPS 上传 个人 中文 中文习惯 关键词 合肥 域名 安全 工作 文件类型 文章管理 时区 未分类 模块 模板 模组 电子地图 界面友好 禅意花园 网速 腾讯 配置管理

分类目录

新浪微博

存档

最近文章

近期评论

友情链接

分享按钮