From 4d2d2c5edcd1d6df32c8ba9d8c4a9cb7db6c0852 Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Wed, 30 Apr 2014 14:58:33 +0000 Subject: [PATCH] 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 --- CHANGES | 3 +++ modules/cache/mod_cache.c | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 0eafe9dc38..267a90ae7b 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 c2b92e9e8c..74c559c727 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 */ -- 2.50.1