From 7ce9abf6182a2be7ddb5a2389da81f31d6ac6b5c Mon Sep 17 00:00:00 2001 From: Graham Leggett Date: Sun, 17 Oct 2010 00:20:41 +0000 Subject: Support Cache-Control: only-if-cached, as per RFC2616 14.9.4. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1023394 13f79535-47bb-0310-9956-ffa450edef68 --- modules/cache/cache_storage.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'modules/cache/cache_storage.c') diff --git a/modules/cache/cache_storage.c b/modules/cache/cache_storage.c index 32105836ab..49b08e4155 100644 --- a/modules/cache/cache_storage.c +++ b/modules/cache/cache_storage.c @@ -304,6 +304,15 @@ int cache_select(cache_request_rec *cache, request_rec *r) if (!fresh) { const char *etag, *lastmod; + /* Cache-Control: only-if-cached and revalidation required, try + * the next provider + */ + if (cache->control_in.only_if_cached) { + /* try again with next cache type */ + list = list->next; + continue; + } + 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); @@ -387,6 +396,15 @@ int cache_select(cache_request_rec *cache, request_rec *r) } } } + + /* if Cache-Control: only-if-cached, and not cached, return 504 */ + if (cache->control_in.only_if_cached) { + ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, + "cache: 'only-if-cached' requested and no cached entity, " + "returning 504 Gateway Timeout for: %s", r->uri); + return HTTP_GATEWAY_TIME_OUT; + } + return DECLINED; } -- cgit v1.2.1