commit fd1dc92fd3722decf25602a84fb01eda2199c460
parent 3ed1cfb557aa71bfe419d092f4cbbc3d53f41851
Author: Andrew Laack <andrew@laack.co>
Date: Fri, 25 Sep 2026 20:51:05 -0500
Readme and cache improvements
Diffstat:
2 files changed, 51 insertions(+), 5 deletions(-)
diff --git a/README b/README
@@ -4,8 +4,7 @@ A gemini browser, written in C++.
Requirements
============
-C++ compiler, make, openssl
-
+C++ compiler, make, openssl, ncurses
Installation
============
@@ -20,3 +19,44 @@ TBD
Examples
========
TBD
+
+Identities
+=========
+These are specified in:
+ $HOME/.gb/{hostname}/client.crt
+ $HOME/.gb/{hostname}/client.key
+
+Or for a non-standard port (port != 1965):
+ $HOME/.gb/{hostname}:{port}/client.crt
+ $HOME/.gb/{hostname}:{port}/client.key
+
+Example:
+ > tree .gb
+ .gb
+ └── bbs.geminispace.org
+ ├── client.crt
+ └── client.key
+
+NOTE: You must have $HOME set in your shell.
+
+Example command to generate keys:
+ openssl req -x509 -newkey rsa:2048 -nodes -days 3650 -keyout client.key -out client.crt -subj "/CN=yourname"
+
+Caching
+=======
+All caching is done in memory with a configurable fifo data structure to limit cached page count.
+There are two seperate instances of the cache object at any given time. One for prefetching and one for history.
+Pages fetched with an identity are never cached, and prefetching never sends requests to hosts you'd use an identity for.
+
+ Prefetch caching:
+
+ One of the main reasons this browser feels so much faster than other gemini protocol browsers is because of its optional prefetch caching.
+ This is enabled by default. When you visit a site without an identity, a thread will be created that fetches the first 10 links on the page.
+ This enables ~ instantaneous visitation of those links. Prefetch caching is only enabled when you aren't using an identity for a domain.
+
+ History caching:
+
+ 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.
diff --git a/src/browser.cpp b/src/browser.cpp
@@ -115,12 +115,16 @@ void 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://") != -1 && !refresh) {
- site = findInCacheAndPromoteIfRelevant(urlString);
+ if(id.crtPath == "" && id.keyPath == "") {
+ site = findInCacheAndPromoteIfRelevant(urlString);
+ }
}
if(site == nullptr) {
@@ -152,7 +156,9 @@ void Browser::goToSite(std::string url, bool addToHistory, bool refresh) {
currentSite = site;
if(urlString.find("gemini://") != -1) {
- visitedCache->addSite(urlString, *site);
+ if(id.keyPath == "" && id.crtPath == "") {
+ visitedCache->addSite(urlString, *site);
+ }
}
for(auto* line: lines) {