Apache Caching and Expires configuration

Posted by mcondiff on Server Fault See other posts from Server Fault or by mcondiff
Published on 2012-06-07T20:26:12Z Indexed on 2012/06/11 4:41 UTC
Read the original article Hit count: 592

I'm looking for a best possible caching/expires configuration for my specific situation.

I realize that some sites have advocated turning etags off: Header unset ETag, FileETag None

I know that I should use either Expires or Cache-Control. In additions, I know that I should use either Last-modified or ETAGs (Per ySlow docs).

I inherited a clients server that uses the following in .htaccess:

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf|xml|txt|html|htm)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
</FilesMatch>

With this server I am not going to be able to rely on staff to rename images, css and js in web applications so I do not want to set the expires far in the future without knowing (with a good certainty) that "most/all" browsers will check to see if content has changed. What I do not want to happen is someone call me and say the website is broken because they replaced an image and it's not showing up.

But I do want to take the most advantage I can with caching and expires while still maintaining that mostly all browsers will check with the server to see if components have changed.

I have access to both the .htaccess and apache .conf file and it is a single server, the content is not deployed on multiple servers.

What would be the best .htaccess or .conf configuration for me to achieve my goals for this clients server?

Thanks for your help

© Server Fault or respective owner

Related posts about apache2

Related posts about cache