commit b31f428712e241487b8058f5688502473f545e34
parent 0b3a087c89ce2f0f63bac183ef203ff484e6408a
Author: Andrew Laack <andrew@laack.co>
Date: Sun, 4 Oct 2026 00:35:20 -0500
Better history caching mechanics
Diffstat:
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/README b/README
@@ -70,7 +70,9 @@ requests to hosts you'd use an identity for.
When you visit a page, the page will be cached after it's loaded.
If the page was in the prefetch cache before, it will be upgraded to the
history cache. This is because visited pages are more important than
- prefetched ones. History caching is disabled when using an identity.
+ prefetched ones. When using identities, history caching only applies
+ for forwards and backwards navigation, but not when visiting a previous
+ site via a link or url.
Identities
==========
diff --git a/src/browser.cpp b/src/browser.cpp
@@ -130,14 +130,14 @@ bool Browser::goToSite(std::string url, bool addToHistory, bool refresh) {
Site* site = nullptr;
- // Caching: when there's an identity we don't read from cache and we don't add sites to the cache
- // additionally, when performing prefetch caching, we check if there's an identity for the site and if there is we
- // don't send a request to it. This means prefetch caching is only used for un-authenticated hosts.
-
Identity id = identityManager.getIdentityForURI(destination->getLinkDestination());
if(urlString.find("gemini://") != std::string::npos && !refresh) {
- if(id.crtPath == "" && id.keyPath == "") {
+ if(id.crtPath != "" && id.keyPath != "") {
+ if(!addToHistory) {
+ site = findInCacheAndPromoteIfRelevant(urlString);
+ }
+ } else {
site = findInCacheAndPromoteIfRelevant(urlString);
}
}
@@ -177,7 +177,7 @@ bool Browser::goToSite(std::string url, bool addToHistory, bool refresh) {
if(urlString.find("gemini://") != std::string::npos) {
int sc = site->getStatusCode();
- if(sc >= 20 && sc <= 29 && id.keyPath == "" && id.crtPath == "") {
+ if(sc >= 20 && sc <= 29) {
visitedCache->addSite(urlString, *site);
}
}