From: Eric Covener Date: Sun, 6 Jul 2014 21:55:03 +0000 (+0000) Subject: * mod_cache: Don't remove stale cache entries that cannot be conditionally X-Git-Tag: 2.2.28~72 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3640a8b69f708d27ffad560b6bd71a21eda1640f;p=thirdparty%2Fapache%2Fhttpd.git * mod_cache: Don't remove stale cache entries that cannot be conditionally revalidated. This prevents the thundring herd protection from serving stale during a revalidation. Reverts most of r572626 which is also gone from later branches. PR 50317. Submitted By: covener, jkaluza, rpluem Reviewed By: covener, jkaluza, ylavic git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@1608302 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 189ed749b75..4b5e9705b69 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes with Apache 2.2.28 + *) mod_cache: Don't remove stale cache entries that cannot be conditionally + revalidated. This prevents the thundring herd protection from serving + stale responses during a revalidation. PR 50317. + [Eric Covener, Jan Kaluza, Ruediger Pluem] *) core: Increase TCP_DEFER_ACCEPT socket option to from 1 to 30 seconds. PR 41270. [Dean Gaudet ] diff --git a/STATUS b/STATUS index ed27fb4015a..b1cbf73861e 100644 --- a/STATUS +++ b/STATUS @@ -99,15 +99,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * mod_cache: Don't remove stale cache entries that cannot be conditionally - revalidated. This prevents the thundring herd protection from serving - stale during a revalidation. Reverts most of r572626 which is also gone - from later branches. PR 50317. - trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1023398 - 2.2.x patch: http://people.apache.org/~covener/patches/httpd-2.2.x-thunder.diff - (+ CHANGES) - +1: covener, jkaluza, ylavic - * mod_rewrite: Support session cookies with the CO= flag when later parameters are used. The doc for this implied the feature had been backported for quite some time. PR56014 diff --git a/modules/cache/cache_storage.c b/modules/cache/cache_storage.c index c9d362719d7..c819f4ca46e 100644 --- a/modules/cache/cache_storage.c +++ b/modules/cache/cache_storage.c @@ -281,6 +281,7 @@ int cache_select(request_rec *r) /* Make response into a conditional */ cache->stale_headers = apr_table_copy(r->pool, r->headers_in); + cache->stale_handle = h; /* We can only revalidate with our own conditionals: remove the * conditions from the original request. @@ -291,12 +292,6 @@ int cache_select(request_rec *r) apr_table_unset(r->headers_in, "If-Range"); apr_table_unset(r->headers_in, "If-Unmodified-Since"); - /* - * Do not do Range requests with our own conditionals: If - * we get 304 the Range does not matter and otherwise the - * entity changed and we want to have the complete entity - */ - apr_table_unset(r->headers_in, "Range"); etag = apr_table_get(h->resp_hdrs, "ETag"); lastmod = apr_table_get(h->resp_hdrs, "Last-Modified"); @@ -314,23 +309,13 @@ int cache_select(request_rec *r) apr_table_set(r->headers_in, "If-Modified-Since", lastmod); } - cache->stale_handle = h; - } - else { - int irv; - /* - * The copy isn't fresh enough, but we cannot revalidate. - * So it is the same case as if there had not been a cached - * entry at all. Thus delete the entry from cache. + * Do not do Range requests with our own conditionals: If + * we get 304 the Range does not matter and otherwise the + * entity changed and we want to have the complete entity */ - irv = cache->provider->remove_url(h, r->pool); - if (irv != OK) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, irv, r->server, - "cache: attempt to remove url from cache unsuccessful."); - } + apr_table_unset(r->headers_in, "Range"); } - return DECLINED; }