You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mi...@apache.org on 2010/10/17 02:20:41 UTC
svn commit: r1023394 - in /httpd/httpd/trunk/modules/cache: cache_storage.c
mod_cache.c
Author: minfrin
Date: Sun Oct 17 00:20:41 2010
New Revision: 1023394
URL: http://svn.apache.org/viewvc?rev=1023394&view=rev
Log:
Support Cache-Control: only-if-cached, as per RFC2616 14.9.4.
Modified:
httpd/httpd/trunk/modules/cache/cache_storage.c
httpd/httpd/trunk/modules/cache/mod_cache.c
Modified: httpd/httpd/trunk/modules/cache/cache_storage.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_storage.c?rev=1023394&r1=1023393&r2=1023394&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/cache_storage.c (original)
+++ httpd/httpd/trunk/modules/cache/cache_storage.c Sun Oct 17 00:20:41 2010
@@ -304,6 +304,15 @@ int cache_select(cache_request_rec *cach
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 *cach
}
}
}
+
+ /* 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;
}
Modified: httpd/httpd/trunk/modules/cache/mod_cache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_cache.c?rev=1023394&r1=1023393&r2=1023394&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_cache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_cache.c Sun Oct 17 00:20:41 2010
@@ -199,9 +199,7 @@ static int cache_quick_handler(request_r
}
else {
/* error */
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
- "cache: error returned while checking for cached "
- "file by '%s' cache", cache->provider_name);
+ return rv;
}
return DECLINED;
}
@@ -478,9 +476,7 @@ static int cache_handler(request_rec *r)
}
else {
/* error */
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
- "cache: error returned while checking for cached "
- "file by %s cache", cache->provider_name);
+ return rv;
}
return DECLINED;
}