1.首先就是在httpd.conf中开启mod_headers模块
2.在.htaccess文件中加入如下配置项,然后重启apache
这个配置项很简单,可以单独设置各种文件类型的缓存时间。
<IfModule mod_headers.c> # htm,html,txt类的文件缓存一个天 <FilesMatch ".(html|htm|txt|js|css)$"> Header set Cache-Control "max-age=86400" </FilesMatch> # css, js, swf类的文件缓存一个月 <FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf)$"> Header set Cache-Control "max-age=2592000" </FilesMatch> </IfModule>