1

这是.htaccess我从互联网上窃取并稍作调整的文件中的一部分

<ifModule mod_headers.c>
  Header set Connection keep-alive
  <filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=2592000, public"
  </filesMatch>
  <filesMatch "\\.(css)$">
    Header set Cache-Control "max-age=604800, public"
  </filesMatch>
  <filesMatch "\\.(js)$">
    Header set Cache-Control "max-age=604800, private"
  </filesMatch>
  <filesMatch "\\.(xml|txt)$">
    Header set Cache-Control "max-age=86400, public, must-revalidate"
  </filesMatch>
  <filesMatch "\\.(html|htm|php)$">
    Header set Cache-Control "max-age=86400, private, must-revalidate"
  </filesMatch>
</ifModule>

我在我的 statik 博客上使用它。我想以index.html不同的方式处理文件并将 max-age 设置为 3600。但我不知道.htaccess文件的工作原理。

4

1 回答 1

1

您可以在最后添加此代码段:

<filesMatch "index\.html$">
    Header set Cache-Control "max-age=3600, private, must-revalidate"
</filesMatch>
于 2013-10-10T19:29:54.453 回答