Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an Apache 2.2 server running mod_proxy. We had a scenario where a response came through from the origin corrupted, it didn't have any content-type or cache-control headers. This meant that downstream proxies and clients cached the dodgy response.

What I would like to do is if the response doesn't have a content-type and cache-control header to insert a Cache-Control:max-age=0, no-cache header

share|improve this question
up vote 2 down vote accepted

I think to do this in Apache, you'd need to be running 2.4. mod_headers is the normal means of manipulating response headers, and it's not flexible enough to do what you want.

In 2.4, something like this should work:

<If "-z resp('Cache-Control') && -z resp('Content-Type')">
    Header set Cache-Control "max-age=0, no-cache"
share|improve this answer

from the rewritecond manual, I haven't tested but it seems that you could do something like:

RewriteCond %{HTTP:Cache-Control} ^$ [AND]
RewriteCond %{HTTP:Content-Type} ^$
Header add Cache-Control:max-age=0, no-cache
share|improve this answer
Unfortunately, that'll work only against request headers, not response headers. – Shane Madden Apr 5 '13 at 6:04
So with mod_header you'll be able to use just Header add – Marcel Apr 5 '13 at 17:07

Your Answer


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.