From 25ce52ee64126caac0550d7086abb79b10e1a951 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 6 Mar 2014 23:55:40 +0000 Subject: only try and cache http and https urls --- content/llcache.c | 35 ++++++++++++++++++++++++++++------- 1 file 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) { -- cgit v1.2.3