Files
captoys/diigo-cache/doc/operate.md
T
dckcandClaude Opus 5.5 992e871c56 feat(diigo-cache): refresh each cache every 3 hours
workerd has no cron triggers, but it runs Durable Object alarms, and
the cache DOs already hold their wiring to the webapp: a refresh
scheduled from inside the DO needs no credential outside it (a systemd
timer would need a cache id to call /api with).

A fill that ends (done or failed) sets an alarm 3 hours out; it starts
a fill that refetches every page through the deepest one holding an
item updated in the last 2 days (page 1 at least, where new bookmarks
land). Refetching overwrites pages in place rather than dropping them
first, so a refresh that fails leaves the cache as it was. stopFill now
also stops a finished job's refreshes.

FillStatus gains refetchThrough (optional; additive). Caches whose fill
ended before this get their first refresh alarm when they next wake.

The service starts at boot as well as on the socket: alarms fire only
while workerd runs.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-14 23:31:48 -05:00

2.7 KiB

Day to day

Create a cache

As in the README, at https://bldbox.tail09e44.ts.net/ instead of localhost: mint, wire, save the ids, fill. Copy the cookie from a browser running on bldbox: diigo accepts it only from the IP it was issued to (see issue 1).

The public page is then https://bldbox.tail09e44.ts.net/public/<diigo username>?days=7, on the tailnet only.

Logs

journalctl -u diigo-cache.service -f -o cat |
  jq -Rr 'fromjson? | "\(.timestamp / 1000 | todate) \(.level) \(.message | gsub("\\s*\\n\\s*"; " "))"'

fromjson? skips lines that aren't JSON: systemd's own ("Started …") and entries from before structuredLogging.

workerd runs with structuredLogging: each entry is one line of JSON, {timestamp, level, message}. message is the logged object as console.log prints it, not JSON: on Cloudflare, Workers Logs indexes the fields of a logged object, so the workers log objects rather than strings.

workerd logs the workers' console.* output: {event: "cache", kind, page, outcome} per page read, {event: "fill", state, …} per fill step (a refresh logs refetchThrough), {event: "mint"}. Ids show only as fingerprints; the cookie never appears.

State

With DynamicUser=yes, systemd keeps the state in /var/lib/private/diigo-cache/ (/var/lib/diigo-cache is a symlink to it), mode 0700, owned by a uid that exists only while the service runs:

Dir Holds Secret?
cache/diigo-cache-DiigoCache/ private caches: every bookmark yes
cache/diigo-cache-PublicCache/ public caches and the username index no
webapp/webapp-WebAppDo/ webapp instances: the diigo cookie yes, a credential

Each Durable Object is one <id hash>.sqlite. Read one with the service stopped, or copy it first: sudo sqlite3 -readonly <file> .tables.

Backups

The private caches are refillable from diigo; the cookie can be re-minted. What's lost with the state is the binding from the ids people saved to these objects. Backups hold the cookie, so treat them as secret.

sudo systemctl stop diigo-cache.socket diigo-cache.service   # the socket would restart it
sudo tar -C /var/lib/private -czf diigo-cache-$(date +%F).tgz diigo-cache
sudo systemctl start diigo-cache.socket

No backup is scheduled (see open issue 6).

When fills log {event: "fill", state: "failed"} with a diigo auth error, mint a fresh webapp instance and wire a new cache. A wired cache refuses a different webapp id (setup in cache.ts) (see open issue 7).