]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
override-expire and override-lastmod options for refresh_pattern
authorwessels <>
Tue, 18 Aug 1998 03:27:30 +0000 (03:27 +0000)
committerwessels <>
Tue, 18 Aug 1998 03:27:30 +0000 (03:27 +0000)
(Henrik Nordstrom)

src/cache_cf.cc
src/cf.data.pre
src/refresh.cc
src/structs.h

index f31b4fad9d32cbd6ad6d5828f6ad7246adb1651e..6ed6ca509ec9d8a6ac7dbcf3f52dbfcf0f32c819 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_cf.cc,v 1.294 1998/07/31 00:15:35 wessels Exp $
+ * $Id: cache_cf.cc,v 1.295 1998/08/17 21:27:30 wessels Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -1109,13 +1109,15 @@ static void
 dump_refreshpattern(StoreEntry * entry, const char *name, refresh_t * head)
 {
     while (head != NULL) {
-       storeAppendPrintf(entry, "%s%s %s %d %d%% %d\n",
+       storeAppendPrintf(entry, "%s%s %s %d %d%% %d%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);
+           (int) head->max / 60,
+           head->flags.override_expire ? " override_expire" : null_string,
+           head->flags.override_lastmod ? " override_lastmod" : null_string);
        head = head->next;
     }
 }
@@ -1128,6 +1130,8 @@ parse_refreshpattern(refresh_t ** head)
     time_t min = 0;
     double pct = 0.0;
     time_t max = 0;
+    int override_expire = 0;
+    int override_lastmod = 0;
     int i;
     refresh_t *t;
     regex_t comp;
@@ -1151,6 +1155,16 @@ parse_refreshpattern(refresh_t ** head)
     pct = (double) i / 100.0;
     GetInteger(i);             /* token: max */
     max = (time_t) (i * 60);   /* convert minutes to seconds */
+    /* Options */
+    while ((token = strtok(NULL, w_space)) != NULL) {
+       if (!strcmp(token, "override-expire"))
+           override_expire = 1;
+       else if (!strcmp(token, "override-expire"))
+           override_lastmod = 1;
+       else
+           debug(22, 0) ("redreshAddToLost: Unknown option '%s': %s\n",
+               pattern, token);
+    }
     if ((errcode = regcomp(&comp, pattern, flags)) != 0) {
        char errbuf[256];
        regerror(errcode, &comp, errbuf, sizeof errbuf);
@@ -1170,6 +1184,10 @@ parse_refreshpattern(refresh_t ** head)
     t->max = max;
     if (flags & REG_ICASE)
        t->flags.icase = 1;
+    if (override_expire)
+       t->flags.override_expire = 1;
+    if (override_lastmod)
+       t->flags.override_lastmod = 1;
     t->next = NULL;
     while (*head)
        head = &(*head)->next;
index b0d871efb8d7f55bbb4b955dea3f28c4834942b6..f1d30a68bad2eb4bc1edbcd5b37bf7af1d1fdb6d 100644 (file)
@@ -1,6 +1,6 @@
 
 #
-# $Id: cf.data.pre,v 1.95 1998/08/14 16:42:02 wessels Exp $
+# $Id: cf.data.pre,v 1.96 1998/08/17 21:27:31 wessels Exp $
 #
 #
 # SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -963,19 +963,32 @@ TYPE: refreshpattern
 LOC: Config.Refresh
 DEFAULT: none
 DOC_START
-       usage: refresh_pattern regex min percent max
+       usage: refresh_pattern regex min percent max [options]
 
        min and max are specified in MINUTES.
        percent is an integer number.
 
+       options: override-expire
+                override-lastmod
+
+               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.
+
+               override-lastmod enforces min age even on objects
+               that was modified recently.
+               
        Please see the file doc/Release-Notes-1.1.txt for a full
        description of Squid's refresh algorithm.  Basically a
-       cached object is:
+       cached object is: (the order is changed from 1.1.X)
 
-               FRESH if age < min
-               STALE if expires < now
                STALE if age > max
-               FRESH if lm-factor < percent
+               FRESH if expires < now, else STALE
+               FRESH if lm-factor < percent, else STALE
+               FRESH if age < min
+               else STALE
 
        The refresh_pattern lines are checked in the order listed here.
        The first entry which matches is used.  If none of the entries
index d54419ec97b2f711eaebdcb31a2f93f9f342ab80..c616ec49c558d2c42ae72a50641c98ff5d949bc7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: refresh.cc,v 1.30 1998/08/17 19:19:35 wessels Exp $
+ * $Id: refresh.cc,v 1.31 1998/08/17 21:27:32 wessels Exp $
  *
  * DEBUG: section 22    Refresh Calculation
  * AUTHOR: Harvest Derived
@@ -100,6 +100,8 @@ refreshCheck(const StoreEntry * entry, request_t * request, time_t delta)
     time_t min = REFRESH_DEFAULT_MIN;
     double pct = REFRESH_DEFAULT_PCT;
     time_t max = REFRESH_DEFAULT_MAX;
+    int override_expire = 0;
+    int override_lastmod = 0;
     const char *pattern = ".";
     time_t age;
     double factor;
@@ -125,6 +127,8 @@ refreshCheck(const StoreEntry * entry, request_t * request, time_t delta)
        pct = R->pct;
        max = R->max;
        pattern = R->pattern;
+       override_expire = R->flags.override_expire;
+       override_lastmod = R->flags.override_lastmod;
     }
     debug(22, 3) ("refreshCheck: Matched '%s %d %d%% %d'\n",
        pattern, (int) min, (int) (100.0 * pct), (int) max);
@@ -139,6 +143,10 @@ refreshCheck(const StoreEntry * entry, request_t * request, time_t delta)
            return 1;
        }
     }
+    if (override_expire && age <= min) {
+       debug(22, 3) ("refreshCheck: NO: age < min && override_expire\n");
+       return 0;
+    }
     if (entry->expires > -1) {
        if (entry->expires <= check_time) {
            debug(22, 3) ("refreshCheck: YES: expires <= curtime\n");
@@ -155,6 +163,10 @@ refreshCheck(const StoreEntry * entry, request_t * request, time_t delta)
        refreshCounts.conf_max_age_stale++;
        return 1;
     }
+    if (override_lastmod && age <= min) {
+       debug(22, 3) ("refreshCheck: NO: age < min && override_lastmod\n");
+       return 0;
+    }
     if (entry->lastmod > -1 && entry->timestamp > entry->lastmod) {
        factor = (double) age / (double) (entry->timestamp - entry->lastmod);
        debug(22, 3) ("refreshCheck: factor = %f\n", factor);
index 24460f30ec12b9ba84ae9696fc97117c4349b747..227f13f0a1ab6fd07c4917572ca3eb3b25bccf60 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.199 1998/08/17 16:44:12 wessels Exp $
+ * $Id: structs.h,v 1.200 1998/08/17 21:27:33 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -206,6 +206,7 @@ struct _delay_spec {
     int restore_bps;
     int max_bytes;
 };
+
 #endif
 
 struct _SquidConfig {
@@ -1230,7 +1231,9 @@ struct _refresh_t {
     time_t max;
     refresh_t *next;
     struct {
-       int icase:1;
+       unsigned int icase:1;
+       unsigned int override_expire:1;
+       unsigned int override_lastmod:1;
     } flags;
 };