Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
    
Why did you disable ETags? –  mgorven Jun 8 '12 at 0:27
    
I didn't turn off etags. What I want is to set a far in the future expires but still have the user check to see if the file has been changed/modified (probably via etags). Any suggestions on the config I should use? –  mcondiff Jun 8 '12 at 14:31

1 Answer 1

Basically, make sure that the server sends Etag and Last-Modified headers (which allows clients to check whether a resource has changed without actually downloading it), and set Expires and Cache-Control: max-age headers as far in the future as you can. If static content is going to be changed without being renamed, then the best you can do is set it such that it covers a typical browsing session (e.g. 15min).

share|improve this answer
    
I've read that you either send etags OR set last modified. But could you come up with something i can put into my .htaccess that would correspond with your answer? –  mcondiff Jun 12 '12 at 20:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.