]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Policy change for negative_ttl
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 5 Jun 2008 12:01:09 +0000 (00:01 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 5 Jun 2008 12:01:09 +0000 (00:01 +1200)
1) wraps all negative_ttl code to now require --enable-http-violations

2) Makes negative_ttl when used, only apply to cached objects without explicit
neg-TTL information.

3) Changes default value to 0, from the previous setting at 5 minutes.

4) Alters negative_ttl documentation to cover the above behavior changes

src/cf.data.pre
src/http.cc
src/store.cc
src/structs.h

index c94f0ee4c784742ee7ff1f224f59c128fb82fba9..3bf9a20f161cfbeaf9f1023d9eafbce73eec693f 100644 (file)
@@ -2876,16 +2876,20 @@ DOC_START
 DOC_END
 
 NAME: negative_ttl
+IFDEF: HTTP_VIOLATIONS
 COMMENT: time-units
 TYPE: time_t
 LOC: Config.negativeTtl
-DEFAULT: 5 minutes
+DEFAULT: 0 seconds
 DOC_START
-       Time-to-Live (TTL) for failed requests.  Certain types of
-       failures (such as "connection refused" and "404 Not Found") are
-       negatively-cached for a configurable amount of time.  The
-       default is 5 minutes.  Note that this is different from
-       negative caching of DNS lookups.
+       Set the Default Time-to-Live (TTL) for failed requests.
+       Certain types of failures (such as "connection refused" and
+       "404 Not Found") are able to be negatively-cached for a short time.
+       Modern web servers should provide Expires: header, however if they
+       do not this can provide a minimum TTL.
+       The default is not to cache errors with unknown expiry details.
+
+       Note that this is different from negative caching of DNS lookups.
 
        WARNING: Doing this VIOLATES the HTTP standard.  Enabling
        this feature could make you liable for problems which it
index e1581445f87c854b47dd807305a0feceea8fbfc1..844f323b2d8114a6b3b544343165d0074b7c1b4c 100644 (file)
@@ -828,9 +828,11 @@ HttpStateData::haveParsedReplyHeaders()
 
     case -1:
 
+#if HTTP_VIOLATIONS
         if (Config.negativeTtl > 0)
             entry->cacheNegatively();
         else
+#endif
             entry->makePrivate();
 
         break;
index b3128915ee52e28b413d5354a351be57f3d250e2..72fcc92cd1dea4d6f861e1cb96a1a8c4613f8348 100644 (file)
@@ -1086,9 +1086,7 @@ StoreEntry::abort()
     assert(mem_obj != NULL);
     debugs(20, 6, "storeAbort: " << getMD5Text());
 
-    lock()
-
-    ;         /* lock while aborting */
+    lock();         /* lock while aborting */
     negativeCache();
 
     releaseRequest();
@@ -1452,10 +1450,21 @@ StoreEntry::checkNegativeHit() const
     return 1;
 }
 
+/**
+ * Set object for negative caching.
+ * Preserves any expiry information given by the server.
+ * In absence of proper expiry info it will set to expire immediately,
+ * or with HTTP-violations enabled the configured negative-TTL is observed
+ */
 void
 StoreEntry::negativeCache()
 {
-    expires = squid_curtime + Config.negativeTtl;
+    if(expires == 0)
+#if HTTP_VIOLATIONS
+        expires = squid_curtime + Config.negativeTtl;
+#else
+        expires = squid_curtime;
+#endif
     EBIT_SET(flags, ENTRY_NEGCACHED);
 }
 
index 9c1352dc061b41f381fc9fbe00e90d9bc73e92a1..bfb24f0f8a890b56ec095df214b4edd7c4b4c79b 100644 (file)
@@ -161,7 +161,9 @@ struct SquidConfig
     int64_t readAheadGap;
     RemovalPolicySettings *replPolicy;
     RemovalPolicySettings *memPolicy;
+#if HTTP_VIOLATIONS
     time_t negativeTtl;
+#endif
     time_t negativeDnsTtl;
     time_t positiveDnsTtl;
     time_t shutdownLifetime;