Override Expires header for proxied content in Apache

apache-2.2

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

Best Answer

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.