From e724672302fe0e44ed431888903223c200cf8f8f Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Wed, 8 Feb 2006 00:35:05 +0000 Subject: [project @ 2006-02-08 00:35:05 by jmb] Handle case where no cache expiry headers are sent; use (now - last_modified) / 10. This should reduce the frequency of cache entry validation. svn path=/import/netsurf/; revision=2064 --- content/fetchcache.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'content/fetchcache.c') diff --git a/content/fetchcache.c b/content/fetchcache.c index 6e3f359f0..62fa07e3f 100644 --- a/content/fetchcache.c +++ b/content/fetchcache.c @@ -111,7 +111,9 @@ struct content * fetchcache(const char *url, freshness_lifetime = (cd->max_age != INVALID_AGE) ? cd->max_age : (cd->expires != 0) ? cd->expires - cd->date : - 0; + (cd->last_modified != 0) ? + (time(0) - cd->last_modified) / 10 : + 0; if (freshness_lifetime > current_age || cd->date == 0) { @@ -127,10 +129,10 @@ struct content * fetchcache(const char *url, /* Ok. We have a cache entry, but it appears stale. * Therefore, validate it. */ - /** \todo perhaps it'd be better to use the - * contents of the Last-Modified header here - * instead */ - date = c->cache_data->date; + if (cd->last_modified) + date = cd->last_modified; + else + date = c->cache_data->date; etag = c->cache_data->etag; } } @@ -585,6 +587,9 @@ void fetchcache_cache_update(struct content *c, talloc_free(c->cache_data->etag); c->cache_data->etag = talloc_strdup(c, data->etag); } + + if (data->last_modified) + c->cache_data->last_modified = data->last_modified; } -- cgit v1.2.3