httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stri...@apache.org
Subject svn commit: r156480 - in httpd/httpd/trunk/modules/cache: cache_util.c mod_cache.c
Date Tue, 08 Mar 2005 02:35:51 GMT
Author: striker
Date: Mon Mar  7 18:35:50 2005
New Revision: 156480

URL: http://svn.apache.org/viewcvs?view=rev&rev=156480
Log:
Improve caching a bit more...

* modules/cache/cache_util.c

  (ap_cache_check_freshness): On Cache-Control/Pragma no-cache force
   revalidation by marking the resource as stale.  Unless IgnoreCacheControl
   is set ofcourse.

 
* modules/cache/mod_cache.c

  (cache_url_handler): Remove Cache-Control/Pragma no-cache check and
   accompagnying comment.

  (cache_save_filter): Move FIXME comment to the correct location.

Modified:
    httpd/httpd/trunk/modules/cache/cache_util.c
    httpd/httpd/trunk/modules/cache/mod_cache.c

Modified: httpd/httpd/trunk/modules/cache/cache_util.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/cache/cache_util.c?view=diff&r1=156479&r2=156480
==============================================================================
--- httpd/httpd/trunk/modules/cache/cache_util.c (original)
+++ httpd/httpd/trunk/modules/cache/cache_util.c Mon Mar  7 18:35:50 2005
@@ -116,6 +116,7 @@
     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;
@@ -154,8 +155,27 @@
      * 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");
@@ -188,8 +208,7 @@
     if (cc_cresp && ap_cache_liststr(r->pool, cc_cresp, "max-age", &val))
{
         maxage_cresp = apr_atoi64(val);
     }
-    else
-    {
+    else {
         maxage_cresp = -1;
     }
 
@@ -279,6 +298,7 @@
         }
         return 1;    /* Cache object is fresh (enough) */
     }
+
     return 0;        /* Cache object is stale */
 }
 

Modified: httpd/httpd/trunk/modules/cache/mod_cache.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/cache/mod_cache.c?view=diff&r1=156479&r2=156480
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_cache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_cache.c Mon Mar  7 18:35:50 2005
@@ -98,39 +98,9 @@
 
     /* 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;
     }
 
     /*
@@ -271,10 +241,6 @@
     /* 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 &&
@@ -426,7 +392,13 @@
              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 &&
@@ -435,6 +407,7 @@
          * 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



Mime
View raw message