From 9619a17b78945cdd444d377d1063d4dac453c532 Mon Sep 17 00:00:00 2001 From: Graham Leggett Date: Sat, 23 Oct 2010 14:11:20 +0000 Subject: [PATCH] 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 --- modules/cache/mod_cache.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/cache/mod_cache.c b/modules/cache/mod_cache.c index bbdec894e1..8d1652486f 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); -- 2.40.0