建站学 - 轻松建站从此开始!

建站学-个人建站指南,网页制作,网站设计,网站制作教程

当前位置: 建站学 > 服务器 > Web服务 >

Linux下配置apache模块:gzip压缩和expires缓存设置

时间:2009-11-18 11:11来源: 作者: 点击:
Linux下配置apache模块:gzip压缩和expires缓存设置
/usr/local/apache111/bin/apxs -i -c /home/software/bak/httpd-2.2.3/modules/metadata/mod_expires.c
/usr/local/apache111/bin/apxs -i -c /home/software/bak/httpd-2.2.3/modules/metadata/mod_headers.c


vi /usr/local/apache111/bin/apr-1-config
改 LDFLAGS="" 为 LDFLAGS="-lz"
/usr/local/apache111/bin/apxs -i -c /home/software/bak/httpd-2.2.3/modules/filters/mod_deflate.c


httpd.conf配置:
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
LoadModule expires_module modules/mod_expires.so

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault A604800
    ExpiresByType text/css M259200
    ExpiresByType application/x-javascript M300
    ExpiresByType image/gif "access plus 2 month"
    ExpiresByType image/jpeg "access plus 2 month"
    ExpiresByType image/png "access plus 2 month"
    ExpiresByType image/x-icon "access plus 2 month"
    ExpiresByType application/x-shockwave-flash A2592000
</IfModule>
<IfModule mod_deflate.c>
    SetOutputFilter DEFLATE

#    DeflateFilterNote Input instream
#    DeflateFilterNote Output outstream
#    DeflateFilterNote Ratio ratio

    LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
    CustomLog logs/deflate_log deflate

    SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI .(?:pdf|mov|avi|mp3|mp4|rm)$ no-gzip dont-vary

    AddOutputFilterByType DEFLATE text/*
    AddOutputFilterByType DEFLATE application/ms* application/vnd* application/postscript application/javascript application/x-javascript
    AddOutputFilterByType DEFLATE application/x-httpd-php application/x-httpd-fastphp

    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4.0[678] no-gzip
    BrowserMatch bMSIE !no-gzip !gzip-only-text/html
</IfModule>

/usr/local/apache111/bin/apachectl -t (责任编辑:admin)
织梦二维码生成器
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片