]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
henrik sez don't cache objects that we can't refresh later
authorwessels <>
Wed, 20 Jan 1999 06:17:58 +0000 (06:17 +0000)
committerwessels <>
Wed, 20 Jan 1999 06:17:58 +0000 (06:17 +0000)
src/http.cc
src/protos.h
src/refresh.cc

index af5debb60a9d63f693202a573d249d22873ef2ee..2156ad6bfd8d65a70ed350ca40201afe46e1c756 100644 (file)
@@ -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)
index c9d776fa9e3db663a652852710d28ac6f2336ff7..3b4ed7c876cb982506bfe44f888b008492935b4e 100644 (file)
@@ -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);
index 90b45944061d0171c9b1383e06b5a033e0180029..58eb38bc64a9f51fcae82de83b1ae88ac5c590ac 100644 (file)
@@ -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",