Home  >  Article  >  php教程  >  apache设置静态文件缓存方法介绍

apache设置静态文件缓存方法介绍

WBOY
WBOYOriginal
2016-06-13 11:32:30956browse

 为了减少客户端对服务端资源的请求,可以开启mod_expires.so模块

在apache%C5%E4%D6%C3/" target="_blank">apache配置文件中去掉这段

“#LoadModule expires_module modules/mod_expires.so

”前面的#号


Httpd.conf配置

 

 代码如下  

ExpiresActive on

#缓存3天。

ExpiresBytype text/css "access plus 3 days

ExpiresByType application/x-javascript "access plus 3 days "

ExpiresByType image/jpeg "access plus 3 days "

Expiresbytype image/gif "access plus 3 days "


加入下面内容

 代码如下  

# mod_expires
ExpiresActive on
ExpiresDefault A864000
ExpiresBytype text/css “access plus 14 days
ExpiresByType text/javascript “access plus 14 days ”
ExpiresByType application/x-javascript “access plus 14 days ”
ExpiresByType application/x-shockwave-flash “access plus 14 days ”
ExpiresByType image/* “access plus 14 days ”
ExpiresByType text/html “access plus 14 days ”

ExpiresDefault A864000

 

默认缓存时间是10天,css缓存时间是14天

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn