diff options
author | Vincent Sanders <vince@kyllikki.org> | 2014-03-06 23:55:40 +0000 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2014-03-09 16:20:53 +0000 |
commit | 25ce52ee64126caac0550d7086abb79b10e1a951 (patch) | |
tree | 05f1948d70abcf7248ff98ca57f520fcee09bbbd /content/llcache.c | |
parent | 8d883978c6d31915f63325b1bc27659ca140bf43 (diff) | |
download | netsurf-25ce52ee64126caac0550d7086abb79b10e1a951.tar.gz netsurf-25ce52ee64126caac0550d7086abb79b10e1a951.tar.bz2 |
only try and cache http and https urls
Diffstat (limited to 'content/llcache.c')
-rw-r--r-- | content/llcache.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/content/llcache.c b/content/llcache.c index fc7757550..7d6e6b64d 100644 --- a/content/llcache.c +++ b/content/llcache.c @@ -1081,23 +1081,44 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags, nserror error; llcache_object *obj; nsurl *defragmented_url; + bool uncachable = false; LLCACHE_LOG(("Retrieve %s (%x, %p, %p)", nsurl_access(url), flags, referer, post)); - /** - * Caching Rules: - * - * 1) Forced fetches are never cached - * 2) POST requests are never cached - */ /* Get rid of any url fragment */ error = nsurl_defragment(url, &defragmented_url); if (error != NSERROR_OK) return error; - if (flags & LLCACHE_RETRIEVE_FORCE_FETCH || post != NULL) { + /* determine if content is cachable */ + if ((flags & LLCACHE_RETRIEVE_FORCE_FETCH) != 0) { + /* Forced fetches are never cached */ + uncachable = true; + } else if (post != NULL) { + /* POST requests are never cached */ + uncachable = true; + } else { + /* only http and https schemes are cached */ + lwc_string *scheme; + bool match; + + scheme = nsurl_get_component(defragmented_url, NSURL_SCHEME); + + if (lwc_string_caseless_isequal(scheme, corestring_lwc_http, + &match) == lwc_error_ok && + (match == false)) { + if (lwc_string_caseless_isequal(scheme, corestring_lwc_https, + &match) == lwc_error_ok && + (match == false)) { + uncachable = true; + } + } + } + + + if (uncachable) { /* Create new object */ error = llcache_object_new(defragmented_url, &obj); if (error != NSERROR_OK) { |