Apache caching with mod_headers mod_expires

Posted by Aaron Moodie on Server Fault See other posts from Server Fault or by Aaron Moodie
Published on 2009-05-30T06:08:03Z Indexed on 2010/06/01 18:04 UTC
Read the original article Hit count: 289

Filed under:
|

Hi, I'm working on homework for uni and was hoping someone could clarify something for me. I need to set up the following:

  • Configure the response header "Cache-Control" to have a "max-age" value of 7 days since access for all image files
  • Configure the response header "Cache-Control" to have a "max-age" value of 5 days since modification for all static HTML files.
  • Configure the response header "Cache-Control" to have a value of "public" for all static HTML and image files.
  • Configure the response header "Cache-Control" to have a value of "private" for all PHP files.

My question is whether it is better to use a FilesMatch, or the mod_expires ExpiresByType to best achieve this? I've so far used the following:

<FilesMatch "\.(gif|jpe?g|png)$">
	ExpiresDefault "access plus 7 days"
	Header set Cache-Control "public"
</FilesMatch>

<FilesMatch "\.(html)$">
	ExpiresDefault "modification plus 5 days"
	Header set Cache-Control "public"
</FilesMatch>

<FilesMatch "\.(php)$">
	Header set Cache-Control "private"
</FilesMatch>

Thanks.

© Server Fault or respective owner

Related posts about apache

Related posts about homework