如何巧用.htaccess设置网站的压缩与缓存

    <IfModule mod_expires.c>
ExpiresActive On
  • ExpiresDefault A86400
ExpiresByType image/gif A2592000
    ExpiresByType image/jpeg A2592000
ExpiresByType image/png A2592000
ExpiresByType application/x-shockwave-flash A2592000
ExpiresByType text/css A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType application/javascript A2592000
ExpiresByType text/javascript A2592000
ExpiresByType text/html A600
</IfModule> <IfModule mod_deflate.c>
<FilesMatch "\.(js|css|html|htm)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule> <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> <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css)$">
Header unset Last-Modified
</FilesMatch> FileETag none

例二:

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A0
# 1 年
<FilesMatch “\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$”>
ExpiresDefault A9030400
</FilesMatch>
# 1 星期
<FilesMatch “\.(jpg|jpeg|png|gif|swf)$”>
ExpiresDefault A604800
</FilesMatch>
# 3 小时
<FilesMatch “\.(txt|xml|js|css)$”>
ExpiresDefault A10800″
</FilesMatch>
</IfModule>

上一篇:iOS UIKit:TableView之编辑模式(3)


下一篇:DB2表结构DDL脚本导出