diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2006-02-08 00:35:05 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2006-02-08 00:35:05 +0000 |
commit | e724672302fe0e44ed431888903223c200cf8f8f (patch) | |
tree | c160669ae9167a8b9e4f8baf985fea77132402b6 /content/fetchcache.c | |
parent | 04e7ec32f9182847a7edc6429bb856f5f086e263 (diff) | |
download | netsurf-e724672302fe0e44ed431888903223c200cf8f8f.tar.gz netsurf-e724672302fe0e44ed431888903223c200cf8f8f.tar.bz2 |
[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
Diffstat (limited to 'content/fetchcache.c')
-rw-r--r-- | content/fetchcache.c | 15 |
1 files changed, 10 insertions, 5 deletions
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; } |