]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug #707: Added functionality to query the origin server for IMS requests.
authorserassio <>
Wed, 22 Dec 2004 23:21:33 +0000 (23:21 +0000)
committerserassio <>
Wed, 22 Dec 2004 23:21:33 +0000 (23:21 +0000)
Original 2.5 STABLE3 patch from Brian.

This adds two new config options:

1.  refresh_all_ims (on/default off) will force all IMS queries to pass
through to the origin server (or parent cache).
2.  refresh_patterns have a refresh-ims option, which does the same, but on a
more selective level.

:wq

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

index 4f0b102b7cb0c3a6967c75d7da116f820aab416b..b401984471b0d5a4f4547588824a9f9549cb7220 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_cf.cc,v 1.460 2004/12/20 16:30:34 robertc Exp $
+ * $Id: cache_cf.cc,v 1.461 2004/12/22 16:21:33 serassio Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -2091,6 +2091,10 @@ dump_refreshpattern(StoreEntry * entry, const char *name, refresh_t * head)
                           (int) head->min / 60,
                           (int) (100.0 * head->pct + 0.5),
                           (int) head->max / 60);
+
+        if (head->flags.refresh_ims)
+            storeAppendPrintf(entry, " refresh-ims");
+
 #if HTTP_VIOLATIONS
 
         if (head->flags.override_expire)
@@ -2133,6 +2137,7 @@ parse_refreshpattern(refresh_t ** head)
     time_t min = 0;
     double pct = 0.0;
     time_t max = 0;
+    int refresh_ims = 0;
 #if HTTP_VIOLATIONS
 
     int override_expire = 0;
@@ -2181,9 +2186,11 @@ parse_refreshpattern(refresh_t ** head)
 
     /* Options */
     while ((token = strtok(NULL, w_space)) != NULL) {
+        if (!strcmp(token, "refresh-ims")) {
+            refresh_ims = 1;
 #if HTTP_VIOLATIONS
 
-        if (!strcmp(token, "override-expire"))
+        } else if (!strcmp(token, "override-expire"))
             override_expire = 1;
         else if (!strcmp(token, "override-lastmod"))
             override_lastmod = 1;
@@ -2203,9 +2210,9 @@ parse_refreshpattern(refresh_t ** head)
             ignore_reload = 1;
             refresh_nocache_hack = 1;
             /* tell client_side.c that this is used */
-        } else
 #endif
 
+        } else
             debug(22, 0) ("redreshAddToList: Unknown option '%s': %s\n",
                           pattern, token);
     }
@@ -2232,6 +2239,9 @@ parse_refreshpattern(refresh_t ** head)
     if (flags & REG_ICASE)
         t->flags.icase = 1;
 
+    if (refresh_ims)
+        t->flags.refresh_ims = 1;
+
 #if HTTP_VIOLATIONS
 
     if (override_expire)
index 9c89c36ce3d60855fdabc6a0f524c4fb27c3b5bc..fa74f456a5308c23cf19b6820549688534571e4d 100644 (file)
@@ -1,6 +1,6 @@
 
 #
-# $Id: cf.data.pre,v 1.367 2004/12/21 17:52:53 robertc Exp $
+# $Id: cf.data.pre,v 1.368 2004/12/22 16:21:33 serassio Exp $
 #
 #
 # SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -2071,6 +2071,7 @@ DOC_START
                 ignore-no-store
                 ignore-private
                 ignore-auth
+                 refresh-ims
 
                override-expire enforces min age even if the server
                sent a Expires: header. Doing this VIOLATES the HTTP
@@ -2112,6 +2113,11 @@ DOC_START
                 this feature could make you liable for problems which
                 it causes.
 
+               refresh-ims causes squid to contact the origin server
+               when a client issues an If-Modified-Since request. This
+               ensures that the client will receive an updated version
+               if one is available.
+
        Basically a cached object is:
 
                FRESH if expires < now, else STALE
@@ -3430,6 +3436,22 @@ DOC_START
        enabled in which case performance will suffer badly anyway..).
 DOC_END
 
+NAME: refresh_all_ims
+COMMENT: on|off
+TYPE: onoff
+DEFAULT: off
+LOC: Config.onoff.refresh_all_ims
+DOC_START
+       When you enable this option, squid will always check
+       the origin server for an update when a client sends an
+       If-Modified-Since request.  Many browsers use IMS
+       requests when the user requests a reload, and this
+       ensures those clients receive the latest version.
+
+       By default (off), squid may return a Not Modified response
+       based on the age of the cached version.
+DOC_END
+
 NAME: reload_into_ims
 IFDEF: HTTP_VIOLATIONS
 COMMENT: on|off
index 411d21321a8df2073289b6fe1184dca7a8262c4f..350056f0c9577506a3d92774cc6e3cf1c0d3b73f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: refresh.cc,v 1.66 2004/12/20 16:30:36 robertc Exp $
+ * $Id: refresh.cc,v 1.67 2004/12/22 16:21:33 serassio Exp $
  *
  * DEBUG: section 22    Refresh Calculation
  * AUTHOR: Harvest Derived
@@ -283,6 +283,13 @@ refreshCheck(const StoreEntry * entry, HttpRequest * request, time_t delta)
     /* request-specific checks */
     if (request) {
         HttpHdrCc *cc = request->cache_control;
+
+        if (request->flags.ims && (R->flags.refresh_ims || Config.onoff.refresh_all_ims)) {
+            /* The clients no-cache header is changed into a IMS query */
+            debug(22, 3) ("refreshCheck: YES: refresh-ims\n");
+            return STALE_FORCED_RELOAD;
+        }
+
 #if HTTP_VIOLATIONS
 
         if (!request->flags.nocache_hack) {
index f0c9c197b562c122fef3299de517897ef27424e0..284da806361398f68accfb0068820501b66b3e3b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.501 2004/12/22 15:10:37 serassio Exp $
+ * $Id: structs.h,v 1.502 2004/12/22 16:21:33 serassio Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -528,6 +528,7 @@ struct _SquidConfig
         int mem_pools;
         int test_reachability;
         int half_closed_clients;
+        int refresh_all_ims;
 #if HTTP_VIOLATIONS
 
         int reload_into_ims;
@@ -1508,6 +1509,9 @@ struct _refresh_t
 
 unsigned int icase:
         1;
+
+unsigned int refresh_ims:
+        1;
 #if HTTP_VIOLATIONS
 
 unsigned int override_expire: