From fef350804ccd87fbb834c4047fc4a67e45370d80 Mon Sep 17 00:00:00 2001 From: dece Date: Sun, 14 Mar 2021 00:05:22 +0100 Subject: [PATCH] browser: add a cache --- bebop/browser.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bebop/browser.py b/bebop/browser.py index 7b7dc1b..0fedac1 100644 --- a/bebop/browser.py +++ b/bebop/browser.py @@ -31,6 +31,7 @@ class Browser: self.status_data = ("", 0, 0) self.current_url = "" self.history = History() + self.cache = {} @property def h(self): @@ -246,6 +247,15 @@ class Browser: After initiating the connection, TODO """ self.set_status(f"Loading {url}") + + if url in self.cache: + self.load_page(self.cache[url]) + if self.current_url and history: + self.history.push(self.current_url) + self.current_url = url + self.set_status(url) + return + req = Request(url, self.stash) connected = req.connect() if not connected: @@ -286,6 +296,7 @@ class Browser: if self.current_url and history: self.history.push(self.current_url) self.current_url = url + self.cache[url] = self.page_pad.current_page self.set_status(url) elif handle_code == 1: self.set_status(f"Downloaded {url}.")