summaryrefslogtreecommitdiff
path: root/modules/cache/cache_storage.c
diff options
context:
space:
mode:
authorGraham Leggett <minfrin@apache.org>2010-10-17 00:20:41 +0000
committerGraham Leggett <minfrin@apache.org>2010-10-17 00:20:41 +0000
commit7ce9abf6182a2be7ddb5a2389da81f31d6ac6b5c (patch)
tree24ee6a83d03dac9e290c787eff926a608b3887f8 /modules/cache/cache_storage.c
parentfc7955190fec8bc130daa36af792a9e0626951a9 (diff)
downloadhttpd-7ce9abf6182a2be7ddb5a2389da81f31d6ac6b5c.tar.gz
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
Diffstat (limited to 'modules/cache/cache_storage.c')
-rw-r--r--modules/cache/cache_storage.c18
1 files changed, 18 insertions, 0 deletions
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;
}