PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
[ start all new proposals below, under PATCHES PROPOSED. ]
- * mod_cache: Honour Cache-Control: no-store in a request.
- trunk patch: http://svn.apache.org/r1479222
- 2.4.x patch: http://people.apache.org/~minfrin/httpd-mod_cache-nostore2.4.patch
- +1: minfrin, jim, wrowe
-
* mod_cache: Ensure that updated responses to HEAD requests don't get
mistakenly paired with a previously cached body. Ensure that any existing
body is removed when a HEAD request is cached.
return apr_file_remove(lockname, r->pool);
}
-CACHE_DECLARE(int) ap_cache_check_allowed(cache_request_rec *cache, request_rec *r) {
- const char *cc_req;
- const char *pragma;
+int ap_cache_check_no_cache(cache_request_rec *cache, request_rec *r)
+{
+
cache_server_conf *conf =
(cache_server_conf *)ap_get_module_config(r->server->module_config,
&cache_module);
* - RFC2616 14.9.4 End to end reload, Cache-Control: no-cache, or Pragma:
* no-cache. The server MUST NOT use a cached copy when responding to such
* a request.
- *
- * - RFC2616 14.9.2 What May be Stored by Caches. If Cache-Control:
- * no-store arrives, do not serve from the cache.
*/
/* This value comes from the client's initial request. */
- cc_req = apr_table_get(r->headers_in, "Cache-Control");
- pragma = apr_table_get(r->headers_in, "Pragma");
-
- ap_cache_control(r, &cache->control_in, cc_req, pragma, r->headers_in);
+ if (!cache->control_in.parsed) {
+ const char *cc_req = cache_table_getm(r->pool, r->headers_in,
+ "Cache-Control");
+ const char *pragma = cache_table_getm(r->pool, r->headers_in, "Pragma");
+ ap_cache_control(r, &cache->control_in, cc_req, pragma, r->headers_in);
+ }
if (cache->control_in.no_cache) {
}
}
+ return 1;
+}
+
+int ap_cache_check_no_store(cache_request_rec *cache, request_rec *r)
+{
+
+ cache_server_conf *conf =
+ (cache_server_conf *)ap_get_module_config(r->server->module_config,
+ &cache_module);
+
+ /*
+ * At this point, we may have data cached, but the request may have
+ * specified that cached data may not be used in a response.
+ *
+ * - RFC2616 14.9.2 What May be Stored by Caches. If Cache-Control:
+ * no-store arrives, do not serve from or store to the cache.
+ */
+
+ /* This value comes from the client's initial request. */
+ if (!cache->control_in.parsed) {
+ const char *cc_req = cache_table_getm(r->pool, r->headers_in,
+ "Cache-Control");
+ const char *pragma = cache_table_getm(r->pool, r->headers_in, "Pragma");
+ ap_cache_control(r, &cache->control_in, cc_req, pragma, r->headers_in);
+ }
+
if (cache->control_in.no_store) {
if (!conf->ignorecachecontrol) {
return 1;
}
-
int cache_check_freshness(cache_handle_t *h, cache_request_rec *cache,
request_rec *r)
{
* @param r request_rec
* @return 0 ==> cache object may not be served, 1 ==> cache object may be served
*/
-CACHE_DECLARE(int) ap_cache_check_allowed(cache_request_rec *cache, request_rec *r);
+int ap_cache_check_no_cache(cache_request_rec *cache, request_rec *r);
+
+/**
+ * Check the whether the request allows a cached object to be stored as per RFC2616
+ * section 14.9.2 (What May be Stored by Caches)
+ * @param cache cache_request_rec
+ * @param r request_rec
+ * @return 0 ==> cache object may not be served, 1 ==> cache object may be served
+ */
+int ap_cache_check_no_store(cache_request_rec *cache, request_rec *r);
/**
* Check the freshness of the cache object per RFC2616 section 13.2 (Expiration Model)
/*
* Are we allowed to serve cached info at all?
*/
+ if (!ap_cache_check_no_store(cache, r)) {
+ return DECLINED;
+ }
/* find certain cache controlling headers */
auth = apr_table_get(r->headers_in, "Authorization");
/* save away the possible providers */
cache->providers = providers;
+ /*
+ * Are we allowed to serve cached info at all?
+ */
+ if (!ap_cache_check_no_store(cache, r)) {
+ return DECLINED;
+ }
+
/* Are we PUT/POST/DELETE? If so, prepare to invalidate the cached entities.
*/
switch (r->method_number) {