From: Graham Leggett Date: Sat, 23 Oct 2010 14:11:20 +0000 (+0000) Subject: mod_cache: Respect the original Cache-Control header if no header arrives X-Git-Tag: 2.3.9~239 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9619a17b78945cdd444d377d1063d4dac453c532;p=thirdparty%2Fapache%2Fhttpd.git mod_cache: Respect the original Cache-Control header if no header arrives with a 304 Not Modified. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1026617 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/cache/mod_cache.c b/modules/cache/mod_cache.c index bbdec894e15..8d1652486f7 100644 --- a/modules/cache/mod_cache.c +++ b/modules/cache/mod_cache.c @@ -868,12 +868,21 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in) cc_out = apr_table_get(r->err_headers_out, "Cache-Control"); pragma = apr_table_get(r->err_headers_out, "Pragma"); headers = r->err_headers_out; - if (cc_out == NULL && pragma == NULL) { + if (!cc_out && !pragma) { cc_out = apr_table_get(r->headers_out, "Cache-Control"); pragma = apr_table_get(r->headers_out, "Pragma"); headers = r->headers_out; } + /* Have we received a 304 response without any headers at all? Fall back to + * the original headers in the original cached request. + */ + if (r->status == HTTP_NOT_MODIFIED && cache->stale_handle && !cc_out + && !pragma) { + cc_out = apr_table_get(cache->stale_handle->resp_hdrs, "Cache-Control"); + pragma = apr_table_get(cache->stale_handle->resp_hdrs, "Pragma"); + } + /* Parse the cache control header */ memset(&control, 0, sizeof(cache_control_t)); ap_cache_control(r, &control, cc_out, pragma, headers);