如何将缓存控制代码添加到htaccess


How can i add cache control code to htaccess?

如何将缓存控制代码添加到.htaccess?

我的网站很慢,我发现了35个没有过期日期的静态组件。

如何添加过期数据?我被告知这可以在.htaccess文件中完成,但我不知道怎么做。

您可以使用这样的东西:

# Cache Files
<filesMatch "'.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>

这会缓存任何以ico|pdf|flv|jpg结尾的文件。。。。。对于604800秒,也就是一周,您可以更改该数字以缓存您认为需要的时间。