From: Graham Leggett Date: Sun, 17 Oct 2010 01:24:24 +0000 (+0000) Subject: Don't attempt to kill a stale entry that cannot be revalidated so early X-Git-Tag: 2.3.9~298 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c7194e2e3608422e19cec08fc317e3a74b3b4784;p=thirdparty%2Fapache%2Fhttpd.git Don't attempt to kill a stale entry that cannot be revalidated so early in the process, as this will happen later anyway as necessary. We may want to serve the stale entry should the backend not be available. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1023398 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/cache/cache_storage.c b/modules/cache/cache_storage.c index 95f1fef0274..6ad5a65f06b 100644 --- a/modules/cache/cache_storage.c +++ b/modules/cache/cache_storage.c @@ -313,6 +313,24 @@ int cache_select(cache_request_rec *cache, request_rec *r) continue; } + /* set aside the stale entry for accessing later */ + cache->stale_headers = apr_table_copy(r->pool, + r->headers_in); + cache->stale_handle = h; + + ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, + "Cached response for %s isn't fresh. Adding/replacing " + "conditional request headers.", r->uri); + + /* We can only revalidate with our own conditionals: remove the + * conditions from the original request. + */ + apr_table_unset(r->headers_in, "If-Match"); + apr_table_unset(r->headers_in, "If-Modified-Since"); + apr_table_unset(r->headers_in, "If-None-Match"); + apr_table_unset(r->headers_in, "If-Range"); + apr_table_unset(r->headers_in, "If-Unmodified-Since"); + etag = apr_table_get(h->resp_hdrs, "ETag"); lastmod = apr_table_get(h->resp_hdrs, "Last-Modified"); @@ -321,30 +339,6 @@ int cache_select(cache_request_rec *cache, request_rec *r) * our own conditionals. */ - ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, - "Cached response for %s isn't fresh. Adding/replacing " - "conditional request headers.", r->uri); - - /* Make response into a conditional */ - cache->stale_headers = apr_table_copy(r->pool, - r->headers_in); - - /* We can only revalidate with our own conditionals: remove the - * conditions from the original request. - */ - apr_table_unset(r->headers_in, "If-Match"); - apr_table_unset(r->headers_in, "If-Modified-Since"); - apr_table_unset(r->headers_in, "If-None-Match"); - 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"); - if (etag) { apr_table_set(r->headers_in, "If-None-Match", etag); } @@ -353,30 +347,18 @@ int cache_select(cache_request_rec *cache, request_rec *r) apr_table_set(r->headers_in, "If-Modified-Since", lastmod); } - cache->stale_handle = h; - - /* ready to revalidate, pretend we were never here */ - return DECLINED; - } - 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"); - /* try again with next cache type */ - list = list->next; - continue; } + /* ready to revalidate, pretend we were never here */ + return DECLINED; } /* Okay, this response looks okay. Merge in our stuff and go. */