From 5655cd8f8c72d0bcd7a9c7586bc9d48cb8c98256 Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Sun, 3 Aug 2014 18:00:48 +0200 Subject: [PATCH] Fixed not working page caching of webkit. If the 'pagecache' option is set to on, this does not really speed up the page load. It seems to be necessary to explicitly set the cache model to use, even if the documentation say that the default cache model is that what is used now. --- src/setting.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/setting.c b/src/setting.c index 9164b05..41f1c0e 100644 --- a/src/setting.c +++ b/src/setting.c @@ -60,6 +60,7 @@ static gboolean setting_add(const char *name, int type, void *value, static void setting_print(Setting *s); static void setting_free(Setting *s); static int webkit(const char *name, int type, void *value, void *data); +static int pagecache(const char *name, int type, void *value, void *data); static int soup(const char *name, int type, void *value, void *data); static int internal(const char *name, int type, void *value, void *data); static int input_color(const char *name, int type, void *value, void *data); @@ -125,7 +126,7 @@ void setting_init() i = SETTING_DEFAULT_FONT_SIZE; setting_add("monofontsize", TYPE_INTEGER, &i, webkit, 0, "default-monospace-font-size"); setting_add("offlinecache", TYPE_BOOLEAN, &on, webkit, 0, "enable-offline-web-application-cache"); - setting_add("pagecache", TYPE_BOOLEAN, &on, webkit, 0, "enable-page-cache"); + setting_add("pagecache", TYPE_BOOLEAN, &on, pagecache, 0, "enable-page-cache"); setting_add("plugins", TYPE_BOOLEAN, &on, webkit, 0, "enable-plugins"); setting_add("print-backgrounds", TYPE_BOOLEAN, &on, webkit, 0, "print-backgrounds"); setting_add("private-browsing", TYPE_BOOLEAN, &off, webkit, 0, "enable-private-browsing"); @@ -524,6 +525,24 @@ static int webkit(const char *name, int type, void *value, void *data) return SETTING_OK; } +static int pagecache(const char *name, int type, void *value, void *data) +{ + int res; + gboolean on = *((gboolean*)value); + + /* first set the setting on the web settings */ + res = webkit(name, type, value, data); + + if (res == SETTING_OK && on) { + webkit_set_cache_model(WEBKIT_CACHE_MODEL_WEB_BROWSER); + } else { + /* reduce memory usage if caching is not used */ + webkit_set_cache_model(WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER); + } + + return res; +} + static int soup(const char *name, int type, void *value, void *data) { const char *property = (const char*)data; -- 2.20.1