]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Add cache_miss_revalidate
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 23 Oct 2013 05:11:22 +0000 (23:11 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 23 Oct 2013 05:11:22 +0000 (23:11 -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.

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

index 900642fc2cb301a259c5c4a7fcb5d6b1784a4a2f..038e16067a1e26a09b88e56493d529c507d2b49e 100644 (file)
@@ -55,14 +55,14 @@ fi
 # might be cross-compiling.
 if test "x$HOSTCXX" = "x"; then
   HOSTCXX="$CXX"
-  if test "x$squid_cv_check_marchnative" = "xyes"; then
-    CXXFLAGS="$CXXFLAGS -march=native"
-  fi
-fi
-if test "x$squid_cv_check_marchnative" = "xyes"; then
-  # always valid for the Host compiler.
-  HOSTCXX="$HOSTCXX -march=native"
-fi
+#  if test "x$squid_cv_check_marchnative" = "xyes"; then
+#    CXXFLAGS="$CXXFLAGS -march=native"
+#  fi
+fi
+#if test "x$squid_cv_check_marchnative" = "xyes"; then
+#  # always valid for the Host compiler.
+#  HOSTCXX="$HOSTCXX -march=native"
+#fi
 AC_SUBST(HOSTCXX)
 
 AC_MSG_CHECKING([simplified host os])
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 0efcf0c7beab364232f93bf115dbf015330d9f95..2e31c12cb8437400ce4f59ac041ee2646e946dbc 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 66839abdbe671e0481ade291a8b566fa37b84036..ae4c0b70270a6832111db1032ef6890f889853ae 100644 (file)
@@ -1008,6 +1008,14 @@ parse_obsolete(const char *name)
 
     if (!strcmp(name, "log_icap"))
         self_destruct();
+
+    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 e3a30f263a3e81da66b3397d19a0bf603b6d4082..2edabd2416c83fc1dc067d1720f402acf235f502 100644 (file)
@@ -149,26 +149,25 @@ DOC_START
        This option is not yet supported by Squid-3.
 DOC_END
 
-NAME: ignore_ims_on_miss
+NAME: location_rewrite_program location_rewrite_access location_rewrite_children location_rewrite_concurrency
 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
+NAME: refresh_stale_hit
 TYPE: obsolete
 DOC_START
        This option is not yet supported by Squid-3.
 DOC_END
 
-NAME: refresh_stale_hit
+# Options Removed in 3.3
+NAME: ignore_ims_on_miss
 TYPE: obsolete
 DOC_START
-       This option is not yet supported by Squid-3.
+       Remove this line. The HTTP/1.1 feature is now fully supported by default.
 DOC_END
 
-# no Options Removed in 3.3
-
 # Options Removed in 3.2
 NAME: ignore_expect_100
 TYPE: obsolete
@@ -7308,6 +7307,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 c7df0195246a8ff2dc26fcddd7922410d0eedda5..78070948637fc9372d7bb4ca71777f95554a4a64 100644 (file)
@@ -1966,12 +1966,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: