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

I found that adding

RewriteRule .* - [E=HTTP_IF_MODIFIED_SINCE:%{HTTP:If-Modified-Since}]
RewriteRule .* - [E=HTTP_IF_NONE_MATCH:%{HTTP:If-None-Match}]

To the bottom of my htaccess file (below all rewriterule) solved my issue (HTTP_IF_MODIFIED_SINCE was not being set) with caching dynamic generated images. Brilliant.

Although what does this actually do and why it is needed? Is it necessary I have this in every .htaccess or can I change the apache server config so I dont have to add this to every website project?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

If-modified since is an HTTP packet header ENV variable which basically sets a time in which if a client has visited a server, and the content which the client is requesting has changed then the server will return the changed content, else it will return a 304 not-modified response without the documents content.

share|improve this answer
    
Ok I understand how it works now thanks. How come I need the setting in the .htacces to make this work though? Would this be related to the apache setup or the PHP CMS with rewrite. –  John Magnolia Dec 18 '11 at 22:31
    
no this is related to php and apache setup, because php cannot access –  s1los Dec 20 '11 at 22:32
    
the php script is recieving info from apache through the $_SERVER superglobal, the above headers mentioned in your script, are grabbed by php, alternatively instead of apache_request_header –  s1los Dec 20 '11 at 22:48

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.