From: Yann Ylavic Date: Wed, 30 Apr 2014 14:58:33 +0000 (+0000) Subject: mod_cache: Preserve non-cacheable headers forwarded from an origin 304 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d48725167b92923f955a1847b9ceb8d86af38c0;p=thirdparty%2Fapache%2Fhttpd.git mod_cache: Preserve non-cacheable headers forwarded from an origin 304 response. PR 55547. When mod_cache asks for a revalidation of a stale entry and the origin responds with a 304 (not that stale), the module strips the non-cacheable headers from the origin response and merges the stale headers to update the cache. The problem is that mod_cache won't forward the non-cacheable headers to the client, for example if the 304 response contains both Set-Cookie and 'Cache-Control: no-cache="Set-Cookie"' headers, or CacheIgnoreHeaders is used. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1591328 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 0eafe9dc38b..267a90ae7ba 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) mod_cache: Preserve non-cacheable headers forwarded from an origin 304 + response. PR 55547. [Yann Ylavic] + *) mod_cache: Don't add cached/revalidated entity headers to a 304 response. PR 55547. [Yann Ylavic] diff --git a/modules/cache/mod_cache.c b/modules/cache/mod_cache.c index c2b92e9e8c1..74c559c727e 100644 --- a/modules/cache/mod_cache.c +++ b/modules/cache/mod_cache.c @@ -1444,10 +1444,14 @@ static apr_status_t cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in) * the cached headers. * * However, before doing that, we need to first merge in - * err_headers_out and we also need to strip any hop-by-hop - * headers that might have snuck in. + * err_headers_out (note that store_headers() below already selects + * the cacheable only headers using ap_cache_cacheable_headers_out(), + * here we want to keep the original headers in r->headers_out and + * forward all of them to the client, including non-cacheable ones). */ - r->headers_out = ap_cache_cacheable_headers_out(r); + r->headers_out = apr_table_overlay(r->pool, r->headers_out, + r->err_headers_out); + apr_table_clear(r->err_headers_out); /* Merge in our cached headers. However, keep any updated values. */ /* take output, overlay on top of cached */