"服务器设置Cache-Control的方法"


title: "服务器设置Cache-Control的方法" layout: post category: 技术-服务器 date: 2016-06-15 16:00:00 +0800 author: hjb2722404 tags: 服务器,Cache-Control,性能优化 status: publish


Apache

.htaccess文件

<filesMatch "\.(ico|gif|jpg|png|jpeg)$"> 
ExpiresActive On 
ExpiresDefault "access plus 11 month" 
Header append Cache-Control "public" 
</filesMatch>

Nginx

.conf文件

location ~* ^.+\.(jpg|jpeg|gif|png|ico)$ 
{ 
expires max; 
}

IIS

config.xml文件

<configuration> 
    <system.webServer> 
        <staticContent> 
            <clientCache cacheControlMode="UseExpires" httpExpires="Tue, 19 Jan 2038 03:14:07 GMT" /> 
        </staticContent> 
    </system.webServer> 
</configuration>