Real-Time Updates
Server-Sent Events Architecture
Lion Reader uses Server-Sent Events (SSE) powered by Redis pub/sub to deliver real-time updates without polling. When a feed worker fetches new content, it publishes events to Redis channels. Your browser maintains an open SSE connection that listens to these channels, receiving updates the moment they happen. This architecture is both efficient and scalable — your connection only subscribes to events for feeds you actually care about.
Channel Types
- Per-feed channels — Each feed has its own channel (
feed:{feedId}:events). When you subscribe to a feed, your SSE connection automatically subscribes to that feed’s channel. This means you only receive events for feeds you follow, reducing noise and bandwidth. - Per-user channels — Account-level events like subscription changes and OPML import progress use a dedicated user channel (
user:{userId}:events). This ensures actions taken in other browser sessions appear instantly across all your devices.
Event Types
Lion Reader sends several types of real-time events:
- new_entry — A new article was published to a feed you subscribe to
- entry_updated — An article’s content was updated by the publisher
- subscription_created — You added a new subscription from another device or session
- import_progress — Real-time status updates during OPML import
Smart Cache Invalidation
When an SSE event arrives, Lion Reader triggers targeted React Query cache invalidations. This means the UI refreshes automatically without manual polling or full page reloads. Optimistic updates for actions like starring and marking entries read mean the UI updates instantly before the server confirms, then reconciles if something went wrong. The result is a responsive interface that feels immediate even on slower connections.
Reliability and Fallbacks
The SSE connection includes a heartbeat keepalive every 30 seconds to detect and recover from network issues. If Redis becomes unavailable, Lion Reader gracefully degrades to a timestamp-based sync endpoint that provides eventual consistency without real-time updates. When you subscribe to a new feed, your SSE connection dynamically starts listening to that feed’s channel without reconnecting, ensuring you never miss new content.