apr_int64_t age, maxage_req, maxage_cresp, maxage, smaxage, maxstale;
apr_int64_t minfresh;
const char *cc_cresp, *cc_req;
+ const char *pragma;
const char *agestr = NULL;
const char *expstr = NULL;
char *val;
* 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)) {
+ cache_server_conf *conf =
+ (cache_server_conf *)ap_get_module_config(r->server->module_config,
+ &cache_module);
+
+ if (!conf->ignorecachecontrol) {
+ /* Treat as stale, causing revalidation */
+ return 0;
+ }
+
+ ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server,
+ "Incoming request may be asking for a uncached version of "
+ "%s, but we know better and are ignoring it",
+ r->unparsed_uri);
+ }
/* These come from the cached entity. */
cc_cresp = apr_table_get(h->resp_hdrs, "Cache-Control");
if (cc_cresp && ap_cache_liststr(r->pool, cc_cresp, "max-age", &val)) {
maxage_cresp = apr_atoi64(val);
}
- else
- {
+ else {
maxage_cresp = -1;
}
}
return 1; /* Cache object is fresh (enough) */
}
+
return 0; /* Cache object is stale */
}
/* 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 response (no-store) and not being allowed to return
- * a cached request without revalidation (max-age=0).
- *
- * Serving from a cache is forbidden under the following circumstances:
- *
- * - RFC2616 14.9.1 Cache-Control: no-cache
- * - Pragma: no-cache
- * - Any requests requiring authorization.
- *
- * Updating a cache is forbidden under the following circumstances:
- * - RFC2616 14.9.2 Cache-Control: no-store
*/
- if (conf->ignorecachecontrol == 1 && auth == NULL) {
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "incoming request may be asking for a uncached version of "
- "%s, but we know better and are ignoring it", url);
- }
- else {
- const char *pragma, *cc_in;
-
- pragma = apr_table_get(r->headers_in, "Pragma");
- cc_in = apr_table_get(r->headers_in, "Cache-Control");
-
- if (auth != NULL ||
- ap_cache_liststr(NULL, pragma, "no-cache", NULL) ||
- ap_cache_liststr(NULL, cc_in, "no-cache", 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;
}
/*
/* If the request has Cache-Control: no-store from RFC 2616, don't store
* unless CacheStoreNoStore is active.
*/
- /* FIXME: The Cache-Control: no-store could have come in on a 304,
- * FIXME: while the original request wasn't conditional. IOW, we made the
- * FIXME: the request conditional earlier to revalidate our cached response.
- */
cc_in = apr_table_get(r->headers_in, "Cache-Control");
if (r->no_cache ||
(!conf->store_nostore &&
ap_cache_liststr(NULL, cc_out, "no-store", NULL)) {
/* RFC2616 14.9.2 Cache-Control: no-store response
* indicating do not cache, or stop now if you are
- * trying to cache it */
+ * trying to cache it.
+ */
+ /* FIXME: The Cache-Control: no-store could have come in on a 304,
+ * FIXME: while the original request wasn't conditional. IOW, we
+ * FIXME: made the the request conditional earlier to revalidate
+ * FIXME: our cached response.
+ */
reason = "Cache-Control: no-store present";
}
else if (!conf->store_private &&
* this object is marked for this user's eyes only. Behave
* as a tunnel.
*/
+ /* FIXME: See above (no-store) */
reason = "Cache-Control: private present";
}
else if (apr_table_get(r->headers_in, "Authorization") != NULL