/*
- * $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
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)
/*
- * $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/
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);
/*
- * $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
#include "squid.h"
typedef enum {
- rcHTTP, rcICP, rcCDigest, rcCount
+ rcHTTP, rcICP, rcCDigest, rcStore, rcCount
} refreshCountsEnum;
static struct RefreshCounts {
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 */
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",