yasar
yasar

Reputation: 13738

How to set cache expiration for index.html

This is a section on my .htaccess file that I stole from the internet and tweaked a bit

<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>

I am using this on my statik blog. I want to treat index.html file differently and set max-age to 3600. But I don't know how exactly .htaccess files work.

Upvotes: 1

Views: 1929

Answers (1)

anubhava
anubhava

Reputation: 784958

You can add this snippet in the end:

<filesMatch "index\.html$">
    Header set Cache-Control "max-age=3600, private, must-revalidate"
</filesMatch>

Upvotes: 1

Related Questions