From: serassio <> Date: Wed, 22 Dec 2004 23:21:33 +0000 (+0000) Subject: Bug #707: Added functionality to query the origin server for IMS requests. X-Git-Tag: SQUID_3_0_PRE4~949 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4c3ef9b20c5e0d23b49c69bee1e148dc22ddcf18;p=thirdparty%2Fsquid.git Bug #707: Added functionality to query the origin server for IMS requests. 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 --- diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 4f0b102b7c..b401984471 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -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) diff --git a/src/cf.data.pre b/src/cf.data.pre index 9c89c36ce3..fa74f456a5 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -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 diff --git a/src/refresh.cc b/src/refresh.cc index 411d21321a..350056f0c9 100644 --- a/src/refresh.cc +++ b/src/refresh.cc @@ -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) { diff --git a/src/structs.h b/src/structs.h index f0c9c197b5..284da80636 100644 --- a/src/structs.h +++ b/src/structs.h @@ -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: