--- mod_cache.c.orig 2005-04-11 17:47:03.000000000 +0200 +++ mod_cache.c 2005-05-19 22:18:55.000000000 +0200 @@ -94,35 +94,13 @@ */ /* find certain cache controlling headers */ - pragma = apr_table_get(r->headers_in, "Pragma"); auth = apr_table_get(r->headers_in, "Authorization"); - /* first things first - does the request allow us to return + /* First things first - does the request allow us to return * cached information at all? If not, just decline the request. - * - * Note that there is a big difference between not being allowed - * to cache a request (no-store) and not being allowed to return - * a cached request without revalidation (max-age=0). - * - * Caching is forbidden under the following circumstances: - * - * - RFC2616 14.9.2 Cache-Control: no-store - * - Pragma: no-cache - * - Any requests requiring authorization. */ - if (conf->ignorecachecontrol == 1 && auth == NULL) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "incoming request is asking for a uncached version of " - "%s, but we know better and are ignoring it", url); - } - else { - if (ap_cache_liststr(NULL, pragma, "no-cache", NULL) || - auth != NULL) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "cache: no-cache or authorization forbids caching " - "of %s", url); - return DECLINED; - } + if (auth) { + return DECLINED; } /* --- cache_util.c.orig 2005-04-10 15:39:03.000000000 +0200 +++ cache_util.c 2005-05-19 22:33:28.000000000 +0200 @@ -130,9 +130,14 @@ const char *cc_cresp, *cc_ceresp, *cc_req; const char *agestr = NULL; const char *expstr = NULL; + const char *pragma; char *val; apr_time_t age_c = 0; cache_info *info = &(h->cache_obj->info); + cache_server_conf *conf = + (cache_server_conf *)ap_get_module_config(r->server->module_config, + &cache_module); + /* * We now want to check if our cached data is still fresh. This depends @@ -166,9 +171,26 @@ * entity, and it's value is in the past, it has expired. * */ + + /* 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"); + + if (ap_cache_liststr(NULL, pragma, "no-cache", NULL) + || ap_cache_liststr(NULL, cc_req, "no-cache", NULL)) { + + if (!conf->ignorecachecontrol) { + /* Treat as stale, causing revalidation */ + return 0; + } + + ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server, + "Incoming request is asking for a uncached version of " + "%s, but we know better and are ignoring it", + r->unparsed_uri); + } cc_cresp = apr_table_get(h->resp_hdrs, "Cache-Control"); cc_ceresp = apr_table_get(h->resp_err_hdrs, "Cache-Control"); - cc_req = apr_table_get(h->req_hdrs, "Cache-Control"); if ((agestr = apr_table_get(h->resp_hdrs, "Age"))) { age_c = apr_atoi64(agestr);