- Added caching_relays unified table with live_enabled/backfill_enabled columns - Separated --reset-backfill from --start-caching as independent flags - Removed redundant caching_enabled master setting; daemon derives from live/backfill - Set caching_inbox_enabled=true by default; removed Inbox toggle from Backfill page - Set caching_live_strategy=cache_all by default - Fixed outbox relay discovery to store ALL discovered relays, not just covering set - Added store_kind_0_information config (default: true) to gate profile sync trigger - Regenerated pg_schema.h from pg_schema.sql to include caching_relays table - Fixed process toggle button styling to match monochrome aesthetic - Fixed radio button styling to match black/white/red theme - Simplified Backfill page: removed Service Status and Inbox Status sections - Backfill status now respects config setting, not just daemon state - Admin config API now bumps caching_config_generation for caching-related changes - make_and_restart_relay.sh now resets PostgreSQL schema on fresh restart
6.6 KiB
Caching Page Redesign: Split Backfill + Caching
Core Decision
Rename the current "Caching" page to "Backfill" (keep all existing UI/API exactly as-is). Create a new "Caching" page for designing the live subscription filter.
The nav becomes:
- Statistics
- Subscriptions
- Configuration
- Authorization
- IP BAN
- Relay Events
- Backfill ← renamed from "Caching"
- Caching ← new page
- DM
- Cleanup
- Database Query
What Stays the Same
The entire backfill system is untouched:
admin/api/caching.php— unchanged, just renamed tobackfill.php(or kept as-is and served under both names)admin/index.php— the current caching section HTML is moved to a "Backfill" sectionadmin/assets/app.js—loadCaching()is renamed toloadBackfill()but logic is identical- All daemon code (
caching/src/backfill.c, etc.) — no changes
What Changes
1. Navigation: admin/index.php
<li><button class="nav-item" data-page="backfill">Backfill</button></li>
<li><button class="nav-item" data-page="caching">Caching</button></li>
2. Backfill Section (moved from current caching section)
The current caching section HTML (lines ~360-409) becomes the "Backfill" section with a new section ID backfillSection. Content is identical — same controls, same status displays, same followed pubkeys table.
3. New Caching Section
A new section for designing the live subscription filter. This is where we configure what the live subscriber sends to upstream relays.
┌─ CACHING (LIVE SUBSCRIPTION) ──────────────────────────┐
│ │
│ Design the Nostr subscription filter: │
│ │
│ Strategy: ○ Whitelist Follows ○ Cache Everything │
│ │
│ authors: [auto-populated from follow graph] (1) │
│ kinds: [1, 7, 9734, ...] │
│ since: [now - 3600s] (lookback window) │
│ limit: [0] (0 = no limit) │
│ │
│ (1) authors is auto-populated in whitelist mode, │
│ empty/absent in cache-everything mode │
│ │
│ Resubscribe interval: [300] seconds │
│ │
│ [Save Configuration] │
│ │
│ Status: Live — receiving events │
│ Events received: 1,234 │
└─────────────────────────────────────────────────────────┘
4. New API Endpoint: admin/api/caching.php
Option A: Create a new file admin/api/live_subscription.php
This is cleaner — separate concerns. The new endpoint handles:
- GET: return current live subscription config + status
- POST: update live subscription config fields
Option B: Keep admin/api/caching.php and add live sub fields
Simpler but muddies the existing file. Since we're renaming the old page to "Backfill", it makes more sense to have a separate file.
Recommendation: Option A — create admin/api/live_subscription.php.
5. New Config Keys
Add to PostgreSQL config table:
| Key | Type | Default | Description |
|---|---|---|---|
caching_live_strategy |
text | whitelist |
whitelist or cache_all |
caching_live_kinds |
text | (value of caching_kinds) |
Kinds filter for live sub |
caching_live_since_seconds |
int | 3600 |
Lookback: since = now - N |
caching_live_limit |
int | 0 |
Max events (0 = no limit) |
caching_live_resubscribe_seconds |
int | 300 |
Resubscribe interval |
6. Admin JS: admin/assets/app.js
Changes:
loadCaching()→ renamed toloadBackfill()(same logic)- New
loadCaching()function for the new page - New save functions for live subscription settings
- Add
backfillto the page map and switch logic - Keep
cachingpointing to the new section
7. Daemon Changes (Phase 2)
Update caching/src/live_subscriber.c to:
- Read
caching_live_strategyfrom config - If
cache_all, omitauthorsfilter - Use configurable kinds, since, limit
- Skip admin sub in cache-all mode
Implementation Order
Phase 1: Admin Page Split (no daemon changes)
- Rename nav item "Caching" → "Backfill"
- Move current caching section HTML to backfill section
- Create new caching section HTML with subscription design UI
- Create
admin/api/live_subscription.php - Update
admin/assets/app.js:- Rename
loadCaching()→loadBackfill() - Add new
loadCaching()for live sub design - Add save functions
- Rename
- Add new config keys to database
Phase 2: Daemon Live Subscriber Changes
- Update
caching/src/config.hwith new live config fields - Update
caching/src/pg_config.cto read new keys - Modify
caching/src/live_subscriber.cto support cache-all mode
Migration
- Existing
caching_live_strategydefaults towhitelist(current behavior) - Existing
caching_live_kindsdefaults to value ofcaching_kinds - Zero behavior change on upgrade — backfill continues as before, live sub continues as before until user changes the strategy
Files Changed
| File | Change |
|---|---|
admin/index.php |
Rename nav, move caching section to backfill, add new caching section |
admin/api/caching.php |
Unchanged (still serves backfill data) |
admin/api/live_subscription.php |
NEW — live subscription config API |
admin/assets/app.js |
Rename loadCaching→loadBackfill, add new loadCaching |
caching/src/config.h |
Add live strategy/kinds/since/limit fields |
caching/src/pg_config.c |
Read new config keys |
caching/src/live_subscriber.c |
Support cache-all mode |