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>
本文深入探讨了如何通过Apache、Nginx和IIS的配置来优化网站性能,重点介绍了使用.htaccess、.conf和config.xml文件进行缓存设置的方法,包括图片、静态资源的过期策略和缓存控制。
1249

被折叠的 条评论
为什么被折叠?



