| name | web-cache |
| description | Local semantic web cache for AI agents — cache web_search and web_extract results locally with embeddings, reducing API costs and enabling offline operation. |
| version | 1.0.0 |
| author | Hermes Cortex |
| license | MIT |
| platforms | ["linux","macos","windows"] |
Web Cache — Local Semantic Cache for Agent Web Results
Overview
web_cache is a transparent cache that sits between you and the web. It stores web_search and web_extract results in a local SQLite database with vector embeddings (via Ollama nomic-embed-text:v1.5), so you can check the cache before making expensive web calls.
Over time, the cache becomes a rich "local internet" — you can answer most common queries from cached knowledge alone, even when offline.
Installation
Installed automatically by install.sh step 10 into ~/.hermes/web-cache/.
Requires: sqlite-vec, requests (installed in a venv at ~/.hermes/web-cache/.venv/)
Usage Protocol — How to Use This in Every Session
1. Before web_search(query) — Check Cache First
cache_result = terminal("""
web_cache search "your search query here"
""")
import json
cache_data = json.loads(cache_result["output"])
if cache_data.get("cached"):
hits = cache_data["hits"]
else:
web_results = web_search("your search query here")
terminal(f"""
echo '{json.dumps(web_results)}' | web_cache store "your search query here" -
""")
2. Before web_extract(url) — Check URL Cache First
cache_result = terminal(f"""
web_cache extract {url}
""")
cache_data = json.loads(cache_result["output"])
if cache_data.get("cached"):
content = cache_data["content"]
else:
content = web_extract(url)
terminal(f"""
echo '{json.dumps(content)}' | web_cache store-extract {url} -
""")
3. Automated Mode
For quick lookups, use auto and auto-extract:
web_cache auto "query"
web_cache auto-extract "https://example.com"
These never make web calls — they only check the cache.
Offline Operation
When you have no internet connection:
- The cache is your only source of truth
- Use
web_cache search <query> — if the answer was cached before, you get it
- Use
web_cache extract <url> — if the page was cached before, you get it
- No internet? No problem — the cache just returns misses for unknown queries
Pro tip: Before going offline, run a broad search session to populate the cache with content you'll need. Or import a cache export from another machine.
Cache Sync (Multi-Machine)
To share cache between machines:
web_cache export ~/web-cache-export.tar.gz
web_cache import ~/web-cache-export.tar.gz
This merges — doesn't overwrite — so both machines accumulate knowledge.
Maintenance
web_cache stats
web_cache prune
web_cache backup ~/backups/
web_cache export ~/backups/web-cache-YYYY-MM-DD.tar.gz
Cron jobs handle nightly pruning and backup automatically.
Design
SQLite + sqlite-vec (vector search)
↓
Dual-mode lookup:
- Semantic similarity for search queries (>0.82 threshold)
- Exact URL match for page extracts
↓
Ollama nomic-embed-text:v1.5 for embeddings (768-dim, local, free)
↓
LRU eviction when >200MB (configurable)
↓
Portable export/import for multi-machine sync
Commands Reference
| Command | Description |
|---|
web_cache search <query> | Semantic search cached queries |
web_cache store <query> [file] | Store search results |
web_cache extract <url> | Check URL cache |
web_cache store-extract <url> [file] | Store extract results |
web_cache prune | LRU eviction over limit |
web_cache stats | Cache statistics |
web_cache backup [path] | Backup DB to file |
web_cache export [path] | Export portable tar.gz |
web_cache import <file> | Import from export |
web_cache clear | Wipe all cached data |
web_cache auto <query> | Cache check only (no web call) |
web_cache auto-extract <url> | URL check only (no web call) |