]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Add cache_miss_revalidate
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 24 Oct 2013 15:35:08 +0000 (09:35 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 24 Oct 2013 15:35:08 +0000 (09:35 -0600)
Port of 2.7 ignore_ims_on_miss directive by Henrik Nordstrom.

This on/off switch enables Squid to convert conditional requests from
clients to non-conditional fetches that can fill the cache faster under
cold-start conditions.

doc/release-notes/release-3.3.sgml
src/SquidConfig.h
src/cache_cf.cc
src/cf.data.pre
src/http.cc

index 9183e374185b5feb65898d7080f964e88297ea4c..5264ba9b9d02eba6bc0758eda0784f4de4cc0c99 100644 (file)
@@ -180,6 +180,12 @@ This section gives a thorough account of those changes in three categories:
 <sect1>New tags<label id="newtags">
 <p>
 <descrip>
+       <tag>cache_miss_revalidate</tag>
+       <p>Whether Squid is to pass-through If-Modified-Since and If-None-Match headers on cache MISS.
+          Revalidation requests can prevent cache gathering objects to HIT on.
+       <p>Based on the Squid-2.7 <em>ignore_ims_on_miss</em> feature.
+       <p><em>IMPORTANT:</em> the meaning for on/off values has changed along with the name since 2.7.
+
        <tag>request_header_add</tag>
        <p>New directive to add custom headers on HTTP traffic sent to upstream servers.
 
@@ -231,7 +237,8 @@ This section gives a thorough account of those changes in three categories:
 <p>
 <descrip>
 
-       <p><em>There are no removed squid.conf options in Squid-3.3.</em>
+       <tag>ignore_ims_on_miss</tag>
+       <p>This option has been replaced by the <em>cache_miss_revalidate</em> feature.
 
 </descrip>
 
@@ -318,9 +325,6 @@ This section gives an account of those changes in three categories:
        <tag>external_refresh_check</tag>
        <p>Not yet ported from 2.7
 
-       <tag>ignore_ims_on_miss</tag>
-       <p>Not yet ported from 2.7
-
        <tag>location_rewrite_access</tag>
        <p>Not yet ported from 2.6
 
index 746f697bee7b3846ec1074b237ff93baa16f141f..58dcddde991c797a0c81d787de34892558cebc99 100644 (file)
@@ -337,6 +337,7 @@ public:
         int check_hostnames;
         int allow_underscore;
         int via;
+        int cache_miss_revalidate;
         int emailErrData;
         int httpd_suppress_version_string;
         int global_internal_static;
index d8bd15923cbb96401bae3026840d3a2b5580900c..1d7de18a3730ed2177abd36033630a4ba23ad3de 100644 (file)
@@ -984,6 +984,14 @@ parse_obsolete(const char *name)
         debugs(3, DBG_CRITICAL, "WARNING: url_rewrite_concurrency upgrade overriding url_rewrite_children settings.");
         Config.redirectChildren.concurrency = cval;
     }
+
+    if (!strcmp(name, "ignore_ims_on_miss")) {
+        // the replacement directive cache_revalidate_on_miss has opposite meanings for ON/OFF value
+        // than the 2.7 directive. We need to parse and invert the configured value.
+        int temp = 0;
+        parse_onoff(&temp);
+        Config.onoff.cache_miss_revalidate = !temp;
+    }
 }
 
 /* Parse a time specification from the config file.  Store the
index 05bc028ec2c370346ad8d237d39006f768aae1c8..4e981731730bf38deb5c1f9e700bf714bc329078 100644 (file)
@@ -135,12 +135,6 @@ DOC_START
        This option is not yet supported by Squid-3.
 DOC_END
 
-NAME: ignore_ims_on_miss
-TYPE: obsolete
-DOC_START
-       This option is not yet supported by Squid-3.
-DOC_END
-
 NAME: location_rewrite_program location_rewrite_access location_rewrite_children location_rewrite_concurrency
 TYPE: obsolete
 DOC_START
@@ -159,6 +153,13 @@ DOC_START
        This option is not yet supported by this version of Squid-3. Please try a later release.
 DOC_END
 
+# Options Removed in 3.3
+NAME: ignore_ims_on_miss
+TYPE: obsolete
+DOC_START
+       Remove this line. The HTTP/1.1 feature is now fully supported by default.
+DOC_END
+
 # Options Removed in 3.2
 NAME: ignore_expect_100
 TYPE: obsolete
@@ -6876,6 +6877,25 @@ DOC_START
        acts on cacheable requests.
 DOC_END
 
+NAME: cache_miss_revalidate
+COMMENT: on|off
+TYPE: onoff
+DEFAULT: on
+LOC: Config.onoff.cache_miss_revalidate
+DOC_START
+       Whether Squid on cache MISS will pass client revalidation requests
+       to the server or tries to fetch new content for caching.
+       This is useful while the cache is mostly empty to more quickly
+       have the cache populated.
+
+       When set to 'on' (default), Squid will pass all client If-* headers
+       to the server.
+
+       When set to 'off' and if the request is cacheable, Squid will
+       remove the clients If-Modified-Since and If-None-Match headers from
+       the request sent to the server.
+DOC_END
+
 NAME: always_direct
 TYPE: acl_access
 LOC: Config.accessList.AlwaysDirect
index fde0656586b7415f0e554b522ad57e68460131ce..5badfcce2040cfbb8ee430456472f133feab34db 100644 (file)
@@ -1978,12 +1978,30 @@ copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, co
 
     case HDR_IF_MODIFIED_SINCE:
         /** \par If-Modified-Since:
-        * append unless we added our own;
-         * \note at most one client's ims header can pass through */
-
-        if (!hdr_out->has(HDR_IF_MODIFIED_SINCE))
+         * append unless we added our own,
+         * but only if cache_miss_revalidate is enabled, or
+         *  the request is not cacheable, or
+         *  the request contains authentication credentials.
+         * \note at most one client's If-Modified-Since header can pass through
+         */
+        // XXX: need to check and cleanup the auth case so cacheable auth requests get cached.
+        if (hdr_out->has(HDR_IF_MODIFIED_SINCE))
+            break;
+        else if (Config.onoff.cache_miss_revalidate || !request->flags.cachable || request->flags.auth)
             hdr_out->addEntry(e->clone());
+        break;
 
+    case HDR_IF_NONE_MATCH:
+        /** \par If-None-Match:
+         * append if the wildcard '*' special case value is present, or
+         *   cache_miss_revalidate is disabled, or
+         *   the request is not cacheable in this proxy, or
+         *   the request contains authentication credentials.
+         * \note this header lists a set of responses for the server to elide sending. Squid added values are extending that set.
+         */
+        // XXX: need to check and cleanup the auth case so cacheable auth requests get cached.
+        if (hdr_out->hasListMember(HDR_IF_MATCH, "*", ',') || Config.onoff.cache_miss_revalidate || !request->flags.cachable || request->flags.auth)
+            hdr_out->addEntry(e->clone());
         break;
 
     case HDR_MAX_FORWARDS: