]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Henrik's refresh_pattern reload patch
authorwessels <>
Fri, 21 Aug 1998 04:45:44 +0000 (04:45 +0000)
committerwessels <>
Fri, 21 Aug 1998 04:45:44 +0000 (04:45 +0000)
src/cache_cf.cc
src/cf.data.pre
src/client_side.cc
src/enums.h
src/globals.h
src/refresh.cc
src/structs.h

index 09f3303ab01c1aad6b0ec355e69549fbe4cb705e..ff4213320a405cb2f1ddd4d79eb3b5e463bf0161 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_cf.cc,v 1.299 1998/08/20 02:49:10 wessels Exp $
+ * $Id: cache_cf.cc,v 1.300 1998/08/20 22:45:44 wessels Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -1115,15 +1115,17 @@ static void
 dump_refreshpattern(StoreEntry * entry, const char *name, refresh_t * head)
 {
     while (head != NULL) {
-       storeAppendPrintf(entry, "%s%s %s %d %d%% %d%s%s\n",
+       storeAppendPrintf(entry, "%s%s %s %d %d%% %d%s%s%s%s\n",
            name,
            head->flags.icase ? " -i" : null_string,
            head->pattern,
            (int) head->min / 60,
            (int) (100.0 * head->pct + 0.5),
            (int) head->max / 60,
-           head->flags.override_expire ? " override_expire" : null_string,
-           head->flags.override_lastmod ? " override_lastmod" : null_string);
+           head->flags.override_expire ? " override-expire" : null_string,
+           head->flags.override_lastmod ? " override-lastmod" : null_string,
+           head->flags.reload_into_ims ? " reload-into-ims" : null_string,
+           head->flags.ignore_reload ? " ignore-reload" : null_string);
        head = head->next;
     }
 }
@@ -1138,6 +1140,8 @@ parse_refreshpattern(refresh_t ** head)
     time_t max = 0;
     int override_expire = 0;
     int override_lastmod = 0;
+    int reload_into_ims = 0;
+    int ignore_reload = 0;
     int i;
     refresh_t *t;
     regex_t comp;
@@ -1167,8 +1171,16 @@ parse_refreshpattern(refresh_t ** head)
            override_expire = 1;
        else if (!strcmp(token, "override-expire"))
            override_lastmod = 1;
-       else
-           debug(22, 0) ("redreshAddToLost: Unknown option '%s': %s\n",
+       else if (!strcmp(token, "reload-into-ims")) {
+           reload_into_ims = 1;
+           refresh_nocache_hack = 1;
+           /* tell client_side.c that this is used */
+       } else if (!strcmp(token, "ignore-reload")) {
+           ignore_reload = 1;
+           refresh_nocache_hack = 1;
+           /* tell client_side.c that this is used */
+       } else
+           debug(22, 0) ("redreshAddToList: Unknown option '%s': %s\n",
                pattern, token);
     }
     if ((errcode = regcomp(&comp, pattern, flags)) != 0) {
@@ -1194,6 +1206,10 @@ parse_refreshpattern(refresh_t ** head)
        t->flags.override_expire = 1;
     if (override_lastmod)
        t->flags.override_lastmod = 1;
+    if (reload_into_ims)
+       t->flags.reload_into_ims = 1;
+    if (ignore_reload)
+       t->flags.ignore_reload = 1;
     t->next = NULL;
     while (*head)
        head = &(*head)->next;
index 26fcb225c53d62992fa37444ceb12e0c0cfa0a09..ee475fe563521de34c7d00bf90efd4da84be1b86 100644 (file)
@@ -1,6 +1,6 @@
 
 #
-# $Id: cf.data.pre,v 1.98 1998/08/17 23:27:59 wessels Exp $
+# $Id: cf.data.pre,v 1.99 1998/08/20 22:45:45 wessels Exp $
 #
 #
 # SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -1008,15 +1008,26 @@ DOC_START
 
        options: override-expire
                 override-lastmod
+                reload-into-ims
+                ignore-reload
 
                override-expire enforces min age even if the server
-               sent a Expires: header. Warning: This breaks HTTP
-               freshness control, and may have servere inpact on
-               the usability of sites that makes correct use of
-               Expires: headers on dynamic data.
+               sent a Expires: header. Doing this VIOLATES the HTTP
+               standard.  Enabling this feature could make you liable
+               for problems which it causes.
 
                override-lastmod enforces min age even on objects
                that was modified recently.
+
+               reload-into-ims changes client no-cache or ``reload''
+               to If-Modified-Since requests. Doing this VIOLATES the
+               HTTP standard. Enabling this feature could make you
+               liable for problems which it causes.
+
+               ignore-reload ignores a client no-cache or ``reload''
+               header. Doing this VIOLATES the HTTP standard. Enabling
+               this feature could make you liable for problems which
+               it causes.
                
        Please see the file doc/Release-Notes-1.1.txt for a full
        description of Squid's refresh algorithm.  Basically a
@@ -2040,6 +2051,9 @@ DOC_START
        Doing this VIOLATES the HTTP standard.  Enabling this
        feature could make you liable for problems which it
        causes.
+       
+       see also refresh_pattern for a more selective approach.
+
 reload_into_ims off
 DOC_END
 
index 0ef3017910c82a0b1655a81f0baec59a877fc41f..aeb44803fc177d790e521005e644d30170588026 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.383 1998/08/19 23:07:23 wessels Exp $
+ * $Id: client_side.cc,v 1.384 1998/08/20 22:45:46 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -680,10 +680,12 @@ clientInterpretRequestHeaders(clientHttpRequest * http)
     if (httpHeaderHas(req_hdr, HDR_PRAGMA)) {
        String s = httpHeaderGetList(req_hdr, HDR_PRAGMA);
        if (strListIsMember(&s, "no-cache", ',')) {
-           if (!Config.onoff.reload_into_ims)
-               EBIT_SET(request->flags, REQ_NOCACHE);
+           if (Config.onoff.reload_into_ims)
+               EBIT_SET(request->flags, REQ_NOCACHE_HACK);
+           else if (refresh_nocache_hack)
+               EBIT_SET(request->flags, REQ_NOCACHE_HACK);
            else
-               EBIT_SET(request->flags, REQ_NOCACHE_IMS);
+               EBIT_SET(request->flags, REQ_NOCACHE);
        }
        stringClean(&s);
     }
@@ -1143,10 +1145,25 @@ clientCacheHit(void *data, char *buf, ssize_t size)
             */
            http->log_type = LOG_TCP_MISS;
            clientProcessMiss(http);
+       } else if (EBIT_TEST(r->flags, REQ_NOCACHE)) {
+           /*
+            * This did not match a refresh pattern that overrides no-cache
+            * we should honour the client no-cache header.
+            */
+           http->log_type = LOG_TCP_CLIENT_REFRESH_MISS;
+           clientProcessMiss(http);
        } else if (r->protocol == PROTO_HTTP) {
+           /*
+            * Object needs to be revalidated
+            * XXX This could apply to FTP as well, if Last-Modified is known.
+            */
            http->log_type = LOG_TCP_REFRESH_MISS;
            clientProcessExpired(http);
        } else {
+           /*
+            * We don't know how to re-validate other protocols. Handle
+            * them as if the object has expired.
+            */
            http->log_type = LOG_TCP_MISS;
            clientProcessMiss(http);
        }
@@ -1577,27 +1594,19 @@ clientProcessRequest2(clientHttpRequest * http)
        /* this object isn't in the cache */
        return LOG_TCP_MISS;
     } else if (!storeEntryValidToSend(e)) {
-       storeRelease(e);
        http->entry = NULL;
        return LOG_TCP_MISS;
     } else if (EBIT_TEST(e->flag, ENTRY_SPECIAL)) {
        /* Special entries are always hits, no matter what the client says */
        http->entry = e;
        return LOG_TCP_HIT;
-    } else if (EBIT_TEST(r->flags, REQ_NOCACHE)) {
-       /* NOCACHE should always eject a negative cached object */
-       if (EBIT_TEST(e->flag, ENTRY_NEGCACHED))
-           storeRelease(e);
-       /* NOCACHE+IMS should not eject a valid object */
-       else if (EBIT_TEST(r->flags, REQ_IMS))
-           (void) 0;
-       /* Request-Range should not eject a valid object */
-       else if (EBIT_TEST(r->flags, REQ_RANGE))
-           (void) 0;
-       else
-           storeRelease(e);
+    } else if (EBIT_TEST(r->flags, REQ_NOCACHE_HACK)) {
+       http->entry = NULL;
        ipcacheReleaseInvalid(r->host);
+       return LOG_TCP_CLIENT_REFRESH_MISS;
+    } else if (EBIT_TEST(r->flags, REQ_NOCACHE)) {
        http->entry = NULL;
+       ipcacheReleaseInvalid(r->host);
        return LOG_TCP_CLIENT_REFRESH_MISS;
     } else {
        http->entry = e;
index d07b3e893b9ec8c338806892c6ae39d7c70ce0c9..32b8329976075e0503ed2a37ab807e5b15b6d1b7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: enums.h,v 1.120 1998/08/20 22:29:58 wessels Exp $
+ * $Id: enums.h,v 1.121 1998/08/20 22:45:47 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -480,7 +480,7 @@ enum {
     REQ_REFRESH,
     REQ_USED_PROXY_AUTH,
     REQ_REDIRECTED,
-    REQ_NOCACHE_IMS            /* for changing no-cache requests into IMS */
+    REQ_NOCACHE_HACK           /* for changing/ignoring no-cache requests */
 };
 
 enum {
index 1d940f669ccdc9e90a342b884341163768a69ef0..317c8e73fb99bbac453eddc1389c8c064877a623 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: globals.h,v 1.63 1998/07/31 00:15:44 wessels Exp $
+ * $Id: globals.h,v 1.64 1998/08/20 22:45:48 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -138,3 +138,4 @@ extern icpUdpData *IcpQueueHead;    /* NULL */
 #if DELAY_POOLS
 extern time_t delay_pools_last_update; /* 0 */
 #endif
+extern int refresh_nocache_hack;       /* 0 */
index c616ec49c558d2c42ae72a50641c98ff5d949bc7..addda2729cc0ffe7bf609d664be8c0dd076108f8 100644 (file)
@@ -1,6 +1,7 @@
 
+
 /*
- * $Id: refresh.cc,v 1.31 1998/08/17 21:27:32 wessels Exp $
+ * $Id: refresh.cc,v 1.32 1998/08/20 22:45:49 wessels Exp $
  *
  * DEBUG: section 22    Refresh Calculation
  * AUTHOR: Harvest Derived
@@ -102,6 +103,8 @@ refreshCheck(const StoreEntry * entry, request_t * request, time_t delta)
     time_t max = REFRESH_DEFAULT_MAX;
     int override_expire = 0;
     int override_lastmod = 0;
+    int reload_into_ims = 0;
+    int ignore_reload = 0;
     const char *pattern = ".";
     time_t age;
     double factor;
@@ -117,11 +120,6 @@ refreshCheck(const StoreEntry * entry, request_t * request, time_t delta)
        refreshCounts.revalidate_stale++;
        return 1;
     }
-    if (EBIT_TEST(request->flags, REQ_NOCACHE_IMS)) {
-       debug(22, 3) ("refreshCheck: YES: Reload into IMS\n");
-       refreshCounts.revalidate_stale++;
-       return 1;
-    }
     if ((R = refreshLimits(uri))) {
        min = R->min;
        pct = R->pct;
@@ -129,13 +127,32 @@ refreshCheck(const StoreEntry * entry, request_t * request, time_t delta)
        pattern = R->pattern;
        override_expire = R->flags.override_expire;
        override_lastmod = R->flags.override_lastmod;
+       reload_into_ims = R->flags.reload_into_ims;
+       ignore_reload = R->flags.ignore_reload;
     }
+    if (!reload_into_ims)
+       reload_into_ims = Config.onoff.reload_into_ims;
     debug(22, 3) ("refreshCheck: Matched '%s %d %d%% %d'\n",
        pattern, (int) min, (int) (100.0 * pct), (int) max);
     age = check_time - entry->timestamp;
     debug(22, 3) ("refreshCheck: age = %d\n", (int) age);
     debug(22, 3) ("\tcheck_time:\t%s\n", mkrfc1123(check_time));
     debug(22, 3) ("\tentry->timestamp:\t%s\n", mkrfc1123(entry->timestamp));
+    if (EBIT_TEST(request->flags, REQ_NOCACHE_HACK)) {
+       if (ignore_reload) {
+           /* The clients no-cache header is ignored */
+           debug(22, 3) ("refreshCheck: MAYBE: ignore-reload\n");
+       } else if (reload_into_ims) {
+           /* The clients no-cache header is changed into a IMS query */
+           debug(22, 3) ("refreshCheck: YES: reload-into-ims\n");
+           return 1;
+       } else {
+           /* The clients no-cache header is not overridden on this request */
+           debug(22, 3) ("refreshCheck: YES: client reload\n");
+           EBIT_SET(request->flags, REQ_NOCACHE);
+           return 1;
+       }
+    }
     if (request->max_age > -1) {
        if (age > request->max_age) {
            debug(22, 3) ("refreshCheck: YES: age > client-max-age\n");
index 3361dcb85a96b63eda7a266ce5eb1bc06f28b67a..41eae7fc485a65c7082c4c631cd0a52b9ab37d53 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.206 1998/08/19 23:10:30 wessels Exp $
+ * $Id: structs.h,v 1.207 1998/08/20 22:45:50 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -79,9 +79,11 @@ struct _acl_deny_info_list {
 };
 
 #if USE_ARP_ACL
+
 struct _acl_arp_data {
     char eth[6];
 };
+
 #endif
 
 struct _String {
@@ -1228,6 +1230,8 @@ struct _refresh_t {
        unsigned int icase:1;
        unsigned int override_expire:1;
        unsigned int override_lastmod:1;
+       unsigned int reload_into_ims:1;
+       unsigned int ignore_reload:1;
     } flags;
 };