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 2013/05/05 03:12:49 UTC
svn commit: r1479222 - in /httpd/httpd/trunk: CHANGES
modules/cache/cache_storage.c modules/cache/cache_util.c
modules/cache/cache_util.h modules/cache/mod_cache.c
Author: minfrin
Date: Sun May 5 01:12:48 2013
New Revision: 1479222
URL: http://svn.apache.org/r1479222
Log:
mod_cache: Honour Cache-Control: no-store in a request.
Modified:
httpd/httpd/trunk/CHANGES
httpd/httpd/trunk/modules/cache/cache_storage.c
httpd/httpd/trunk/modules/cache/cache_util.c
httpd/httpd/trunk/modules/cache/cache_util.h
httpd/httpd/trunk/modules/cache/mod_cache.c
Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1479222&r1=1479221&r2=1479222&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Sun May 5 01:12:48 2013
@@ -1,6 +1,8 @@
-*- coding: utf-8 -*-
Changes with Apache 2.5.0
+ *) mod_cache: Honour Cache-Control: no-store in a request. [Graham Leggett]
+
*) mod_cache: RFC2616 14.9.3 The s-maxage directive also implies the
semantics of the proxy-revalidate directive. [Graham Leggett]
Modified: httpd/httpd/trunk/modules/cache/cache_storage.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_storage.c?rev=1479222&r1=1479221&r2=1479222&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/cache_storage.c (original)
+++ httpd/httpd/trunk/modules/cache/cache_storage.c Sun May 5 01:12:48 2013
@@ -199,6 +199,13 @@ int cache_select(cache_request_rec *cach
return DECLINED;
}
+ /* if no-cache, we can't serve from the cache, but we may store to the
+ * cache.
+ */
+ if (!ap_cache_check_no_cache(cache, r)) {
+ return DECLINED;
+ }
+
if (!cache->key) {
rv = cache_generate_key(r, r->pool, &cache->key);
if (rv != APR_SUCCESS) {
@@ -206,10 +213,6 @@ int cache_select(cache_request_rec *cach
}
}
- if (!ap_cache_check_allowed(cache, r)) {
- return DECLINED;
- }
-
/* go through the cache types till we get a match */
h = apr_palloc(r->pool, sizeof(cache_handle_t));
Modified: httpd/httpd/trunk/modules/cache/cache_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_util.c?rev=1479222&r1=1479221&r2=1479222&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/cache_util.c (original)
+++ httpd/httpd/trunk/modules/cache/cache_util.c Sun May 5 01:12:48 2013
@@ -410,9 +410,9 @@ apr_status_t cache_remove_lock(cache_ser
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);
@@ -427,16 +427,15 @@ CACHE_DECLARE(int) ap_cache_check_allowe
* - 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) {
@@ -451,6 +450,32 @@ CACHE_DECLARE(int) ap_cache_check_allowe
}
}
+ 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) {
@@ -468,7 +493,6 @@ CACHE_DECLARE(int) ap_cache_check_allowe
return 1;
}
-
int cache_check_freshness(cache_handle_t *h, cache_request_rec *cache,
request_rec *r)
{
Modified: httpd/httpd/trunk/modules/cache/cache_util.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_util.h?rev=1479222&r1=1479221&r2=1479222&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/cache_util.h (original)
+++ httpd/httpd/trunk/modules/cache/cache_util.h Sun May 5 01:12:48 2013
@@ -239,7 +239,16 @@ typedef struct {
* @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)
Modified: httpd/httpd/trunk/modules/cache/mod_cache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_cache.c?rev=1479222&r1=1479221&r2=1479222&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_cache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_cache.c Sun May 5 01:12:48 2013
@@ -102,6 +102,9 @@ static int cache_quick_handler(request_r
/*
* 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");
@@ -401,6 +404,13 @@ static int cache_handler(request_rec *r)
/* 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) {
Re: svn commit: r1479222 - in /httpd/httpd/trunk: CHANGES modules/cache/cache_storage.c modules/cache/cache_util.c modules/cache/cache_util.h modules/cache/mod_cache.c
Posted by Graham Leggett <mi...@sharp.fm>.
On 05 May 2013, at 4:34 PM, Ruediger Pluem <rp...@apache.org> wrote:
>> Modified: httpd/httpd/trunk/modules/cache/cache_util.c
>> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_util.c?rev=1479222&r1=1479221&r2=1479222&view=diff
>> ==============================================================================
>> --- httpd/httpd/trunk/modules/cache/cache_util.c (original)
>> +++ httpd/httpd/trunk/modules/cache/cache_util.c Sun May 5 01:12:48 2013
>> @@ -410,9 +410,9 @@ apr_status_t cache_remove_lock(cache_ser
>> 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)
>> +{
>> +
>
> Why no longer CACHE_DECLARE(int)?
Because it never appeared in a public header.
Ideally this function should be called cache_check_no_cache(), not ap_cache_check_no_cache().
Regards,
Graham
--
Re: svn commit: r1479222 - in /httpd/httpd/trunk: CHANGES modules/cache/cache_storage.c
modules/cache/cache_util.c modules/cache/cache_util.h modules/cache/mod_cache.c
Posted by Ruediger Pluem <rp...@apache.org>.
minfrin@apache.org wrote:
> Author: minfrin
> Date: Sun May 5 01:12:48 2013
> New Revision: 1479222
>
> URL: http://svn.apache.org/r1479222
> Log:
> mod_cache: Honour Cache-Control: no-store in a request.
>
> Modified:
> httpd/httpd/trunk/CHANGES
> httpd/httpd/trunk/modules/cache/cache_storage.c
> httpd/httpd/trunk/modules/cache/cache_util.c
> httpd/httpd/trunk/modules/cache/cache_util.h
> httpd/httpd/trunk/modules/cache/mod_cache.c
>
> Modified: httpd/httpd/trunk/modules/cache/cache_util.c
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_util.c?rev=1479222&r1=1479221&r2=1479222&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/modules/cache/cache_util.c (original)
> +++ httpd/httpd/trunk/modules/cache/cache_util.c Sun May 5 01:12:48 2013
> @@ -410,9 +410,9 @@ apr_status_t cache_remove_lock(cache_ser
> 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)
> +{
> +
Why no longer CACHE_DECLARE(int)?
Regards
RĂ¼diger