PR 24884 points out an issue I was already working on for other reasons.

An initial request for a file (say a gif file) which has an ExpiresByType
specified for it (image/gif A300) receives an Expires header in the response.

Subsequent requests with an If-Modified-Since and/or If-None-Match request
header correctly receive a 304 response, but no Expires header. So the
browser can't update the expiry in its cache.

The problem is as follows:
  - The expires_filter is AP_FTYPE_CONTENT_SET (which is less than AP_FTYPE_PROTOCOL).
  - The default_handler (around line 3493 of core.c) has the following code:
        if ((errstatus = ap_meets_conditions(r)) != OK) {
            apr_file_close(fd);
            return errstatus;
        }
     which results in a 304 being returned without any brigades passing though the
     filter chain.
  - The 304 is later processed by ap_send_error_response (line 2358 of http_protocol)
  - ap_send_error_response has set the filter chain to r->proto_output_filters
     (which only contains filters types >= AP_FTYPE_PROTOCOL and doesn't include
      the expires_filter).

  Thus, even though the expires_filter *is* initially added to the chain and it *could*
  be run against the 304 (the content type isn't altered in ap_send_error_response by
  the time ap_finalize_request_protocol is called, which ultimately passes the 304 down
  the modified filter chain), it doesn't ever get the chance.

Question:
-------------------
How do I correctly adjust the ap_send_error_response code to include the expires_filter
(and other similar filters) in the error path?

Hint: I can't just change expires_filter to AP_FTYPE_PROTOCOL. Doing this *does*
      result in the expires_filter being called, but the expires headers (Expires
      and Cache-Control:max-age) don't show up in the response. This could probably
      be fixed with a little extra sleuthing, but there is another problem with this
      solution. Under *normal* circumstances (i.e. a 200 response) the deflate module
      is no longer called. This might also be able to be worked around, but concerns
      me enough to ask for other ideas.

--
Paul J. Reder
-----------------------------------------------------------
"The strength of the Constitution lies entirely in the determination of each
citizen to defend it.  Only if every single citizen feels duty bound to do
his share in this defense are the constitutional rights secure."
-- Albert Einstein




Reply via email to