I am serving proxied content with Apache that already contains an Expires header. Using mod_expires' ExpireDefault to override the already present Expires header does not work, the old header is left untouched.

Is there another way to override the Expires header? I tried using mod_headers, but it seems I cannot do date calculation there. I also must override the Expires header, I cannot use Cache-Control with max-age for this.

Regards, Jochen


As per the HTTP 1.1 specification:

A transparent proxy MUST NOT modify any of the following fields in a response:

  - Expires

but it MAY add any of these fields if not already present. If an Expires header is added, it MUST be given a field-value identical to that of the Date header in that response.

(Quoted from the spec at W3.org.)

You can probably do it using some other hack. An intermediate proxy (such as WebScarab, which I wouldn't use in any production environment) might allow you to intercept and modify any of the headers but a standards-compliant HTTP proxy such as Apache will not permit you to override the Expires header. You can only add it if it's not already there from the origin server, but I'm guessing that the restriction from the spec for adding the Expires header is not going to do what you're looking to do.

  • We need to to this even if we bring the wrath of the W3C upon us... The setup is Apache + Tomcat, Tomcat generates the headers, and we need to override them in Apache...
    – Jochen
    Jan 21 '11 at 16:15
  • @Jochen Right, I understand. Just saying that you'll likely not be able to do that using Apache as it's a standards-compliant server, unless you hack the source and compile it in yourself.
    – squillman
    Jan 21 '11 at 16:40
  • He's using Apache httpd as a reverse proxy! Not a transparent proxy, ProxyRequests is probably set to Off. That means, the apache server itself is a webserver and dynamic content happens to come from a "Proxied" ajp connection.
    – Jaap
    Oct 22 '12 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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