Added new settings maximum-cache-size to set the size all the cache may use.
Default is 2000kB.
you have to escape the '|' as '\\|' else the '|' will terminate the :set
command and start a new command.
.TP
+.B maximum-cache-size (int)
+Size in kB used to cache various page data. This caching is independent from
+`pagecache' or `offlinecache'. To disable caching, the size could be set to '0'.
+.TP
.B previouspattern (list)
Patterns to use when guessing the previous page in a document. Each pattern is
successively tested against each link in the page beginning from the last
#endif
/* enable HTTP Strict-Transport-Security*/
#define FEATURE_HSTS
-
+/* enable soup caching - size can be configure by maximum-cache-size setting */
+#define FEATURE_SOUP_CACHE
/* time in seconds after that message will be removed from inputbox if the
* message where only temporary */
* when the setting hsts=on */
vb.config.hsts_provider = hsts_provider_new();
#endif
+#ifdef FEATURE_SOUP_CACHE
+ /* setup the soup cache but without setting the cache size - this is done in setting.c */
+ char *cache_dir = util_get_cache_dir();
+ vb.config.soup_cache = soup_cache_new(cache_dir, SOUP_CACHE_SINGLE_USER);
+ soup_session_add_feature(vb.session, SOUP_SESSION_FEATURE(vb.config.soup_cache));
+ soup_cache_load(vb.config.soup_cache);
+ g_free(cache_dir);
+#endif
}
static void session_cleanup(void)
g_object_unref(vb.config.hsts_provider);
soup_session_remove_feature_by_type(vb.session, HSTS_TYPE_PROVIDER);
#endif
+#ifdef FEATURE_SOUP_CACHE
+ /* commit all cache writes */
+ soup_cache_flush(vb.config.soup_cache);
+ /* make sure that the cache will be kept on next browser start */
+ soup_cache_dump(vb.config.soup_cache);
+#endif
}
static void register_init(void)
gboolean kioskmode;
#ifdef FEATURE_HSTS
HSTSProvider *hsts_provider; /* the hsts session feature that is added to soup session */
+#endif
+#ifdef FEATURE_SOUP_CACHE
+ SoupCache *soup_cache; /* soup caching feature model */
#endif
GHashTable *settings;
} Config;
#ifdef FEATURE_HSTS
static int hsts(const char *name, int type, void *value, void *data);
#endif
+#ifdef FEATURE_SOUP_CACHE
+static int soup_cache(const char *name, int type, void *value, void *data);
+#endif
static gboolean validate_js_regexp_list(const char *pattern);
void setting_init()
setting_add("download-use-external", TYPE_BOOLEAN, &off, NULL, 0, NULL);
#ifdef FEATURE_HSTS
setting_add("hsts", TYPE_BOOLEAN, &on, hsts, 0, NULL);
+#endif
+#ifdef FEATURE_SOUP_CACHE
+ i = 2000;
+ setting_add("maximum-cache-size", TYPE_INTEGER, &i, soup_cache, 0, NULL);
#endif
setting_add("x-hint-command", TYPE_CHAR, &":o <C-R>;", NULL, 0, NULL);
}
#endif
+#ifdef FEATURE_SOUP_CACHE
+static int soup_cache(const char *name, int type, void *value, void *data)
+{
+ int kilobytes = *(int*)value;
+
+ soup_cache_set_max_size(vb.config.soup_cache, kilobytes * 1000);
+
+ /* clear the cache if maximum-cache-size is set to zero - note that this
+ * will also effect other vimb instances */
+ if (!kilobytes) {
+ soup_cache_clear(vb.config.soup_cache);
+ }
+ return SETTING_OK;
+}
+#endif
+
/**
* Validated syntax given list of JavaScript RegExp patterns.
* If validation fails, the error is shown to the user.
return path;
}
+/**
+ * Retrieves the path to the cach dir.
+ * Returned string must be freed.
+ */
char *util_get_cache_dir(void)
{
char *path = g_build_filename(g_get_user_cache_dir(), PROJECT, NULL);