From: wessels <> Date: Wed, 20 Jan 1999 06:17:58 +0000 (+0000) Subject: henrik sez don't cache objects that we can't refresh later X-Git-Tag: SQUID_3_0_PRE1~2372 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cfa9f1cb9a54332ac140270136424e896dae7919;p=thirdparty%2Fsquid.git henrik sez don't cache objects that we can't refresh later --- diff --git a/src/http.cc b/src/http.cc index af5debb60a..2156ad6bfd 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.342 1999/01/19 02:24:27 wessels Exp $ + * $Id: http.cc,v 1.343 1999/01/19 23:17:58 wessels Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -220,6 +220,12 @@ httpCachableReply(HttpStateData * httpState) case HTTP_MULTIPLE_CHOICES: case HTTP_MOVED_PERMANENTLY: case HTTP_GONE: + /* + * Don't cache objects that need to be refreshed on next request, + * unless we know how to refresh it. + */ + if (!refreshIsCachable(httpState->entry)) + return 0; /* don't cache objects from peers w/o LMT, Date, or Expires */ /* check that is it enough to check headers @?@ */ if (rep->date > -1) diff --git a/src/protos.h b/src/protos.h index c9d776fa9e..3b4ed7c876 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.307 1999/01/19 21:40:42 wessels Exp $ + * $Id: protos.h,v 1.308 1999/01/19 23:18:00 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -663,6 +663,7 @@ extern void authenticateInit(void); extern void authenticateShutdown(void); extern void refreshAddToList(const char *, int, time_t, int, time_t); +extern int refreshIsCachable(const StoreEntry *); extern int refreshCheckHTTP(const StoreEntry *, request_t *); extern int refreshCheckICP(const StoreEntry *, request_t *); extern int refreshCheckDigest(const StoreEntry *, time_t delta); diff --git a/src/refresh.cc b/src/refresh.cc index 90b4594406..58eb38bc64 100644 --- a/src/refresh.cc +++ b/src/refresh.cc @@ -1,7 +1,7 @@ /* - * $Id: refresh.cc,v 1.46 1999/01/11 22:23:07 wessels Exp $ + * $Id: refresh.cc,v 1.47 1999/01/19 23:18:01 wessels Exp $ * * DEBUG: section 22 Refresh Calculation * AUTHOR: Harvest Derived @@ -41,7 +41,7 @@ #include "squid.h" typedef enum { - rcHTTP, rcICP, rcCDigest, rcCount + rcHTTP, rcICP, rcCDigest, rcStore, rcCount } refreshCountsEnum; static struct RefreshCounts { @@ -255,6 +255,34 @@ refreshCheck(const StoreEntry * entry, request_t * request, time_t delta, struct return 1; } +int +refreshIsCachable(const StoreEntry * entry) +{ + /* + * Don't look at the request to avoid no-cache and other nuisances. + * the object should have a mem_obj so the URL will be found there. + * 60 seconds delta, to avoid objects which expire almost + * immediately, and which can't be refreshed. + */ + if (!refreshCheck(entry, NULL, 60, &refreshCounts[rcStore])) + /* Does not need refresh. This is certainly cachable */ + return 1; + if (entry->lastmod < 0) + /* Last modified is needed to do a refresh */ + return 0; + if (entry->mem_obj == NULL) + /* no mem_obj? */ + return 1; + if (entry->mem_obj->reply) + /* no reply? */ + return 1; + if (entry->mem_obj->reply->content_length == 0) + /* No use refreshing (caching?) 0 byte objects */ + return 0; + /* This seems to be refreshable. Cache it */ + return 1; +} + /* refreshCheck... functions below are protocol-specific wrappers around * refreshCheck() function above */ @@ -357,6 +385,7 @@ refreshInit() memset(refreshCounts, 0, sizeof(refreshCounts)); refreshCounts[rcHTTP].proto = "HTTP"; refreshCounts[rcICP].proto = "ICP"; + refreshCounts[rcStore].proto = "On Store"; refreshCounts[rcCDigest].proto = "Cache Digests"; cachemgrRegister("refresh",