summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Querna <pquerna@apache.org>2008-12-07 06:33:02 +0000
committerPaul Querna <pquerna@apache.org>2008-12-07 06:33:02 +0000
commit24f396ce7620d75006c50fc12b6e5e86709c298c (patch)
tree666cb87c19eb455893111e3bf57df32ca3dea056
parent0a0ac63f297e7676a143dd0f9b03e3b7d1e5683f (diff)
downloadhttpd-24f396ce7620d75006c50fc12b6e5e86709c298c.tar.gz
When an expires or cache-control header are sent, the RFC does allow us to cache normally non-cacheable response statuses.
Submitted by: Alex Polvi <alex polvi.net> git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@724093 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--CHANGES4
-rw-r--r--modules/cache/mod_cache.c23
2 files changed, 26 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index c8a1fb8739..ed982bc7b2 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
-*- coding: utf-8 -*-
Changes with Apache 2.3.0
[ When backported to 2.2.x, remove entry from this file ]
+
+ *) mod_cache: When an explicit Expires or Cache-Control header is set, cache
+ normally non-cacheable response statuses. PR 46346.
+ [Alex Polvi <alex polvi.net>]
*) mod_ratelimit: New module to do bandwidth rate limiting. [Paul Querna]
diff --git a/modules/cache/mod_cache.c b/modules/cache/mod_cache.c
index 945adb6b7b..dce16fe457 100644
--- a/modules/cache/mod_cache.c
+++ b/modules/cache/mod_cache.c
@@ -438,7 +438,28 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in)
* We include 304 Not Modified here too as this is the origin server
* telling us to serve the cached copy.
*/
- reason = apr_psprintf(p, "Response status %d", r->status);
+ if (exps != NULL || cc_out != NULL) {
+ /* We are also allowed to cache any response given that it has a
+ * valid Expires or Cache Control header. If we find a either of
+ * those here, we pass request through the rest of the tests. From
+ * the RFC:
+ *
+ * A response received with any other status code (e.g. status
+ * codes 302 and 307) MUST NOT be returned in a reply to a
+ * subsequent request unless there are cache-control directives or
+ * another header(s) that explicitly allow it. For example, these
+ * include the following: an Expires header (section 14.21); a
+ * "max-age", "s-maxage", "must-revalidate", "proxy-revalidate",
+ * "public" or "private" cache-control directive (section 14.9).
+ */
+ }
+ else {
+ reason = apr_psprintf(p, "Response status %d", r->status);
+ }
+ }
+
+ if (reason) {
+ /* noop */
}
else if (exps != NULL && exp == APR_DATE_BAD) {
/* if a broken Expires header is present, don't cache it */