Skip to content

Add offline user cache to allow clients to connect during panel downtime #32

@kilyabin

Description

@kilyabin

Feature

Implement the ability for clients to connect using an offline user cache when the PasarGuard/panel is down or temporarily unavailable.

Background

Currently, if the panel fails or loses network access, new and returning clients cannot authenticate or connect because user data is not available from the panel. This impacts service reliability and user experience, especially in environments where uptime and censorship resistance is critical.

Proposal

  • Integrate a persistent offline cache for user data in the node backend.
  • On successful user synchronization, save user information locally (e.g., as JSON, or using SQLite for reliability).
  • During panel downtime, the backend should allow clients to authenticate using cached user data for a configurable time period (TTL).
  • Add configuration fields for cache location, enable/disable offline mode, and cache validity period.
  • Provide API to load cached users and fallback to offline mode when user sync from panel is unavailable.
  • Optionally, allow cache invalidation or manual refresh when the panel is back online.

Implementation Suggestions

  • Add a new storage layer (JSON file, SQLite DB, etc.) for user cache in the backend.
  • Save users upon successful sync and load from cache when panel is unreachable.
  • Expose fallback endpoints to serve clients in offline mode.
  • Handle TTL to ensure stale cache is not used indefinitely.

Benefits

  • Increased resilience for clients during network outages or panel downtime.
  • Improved reliability for censorship-resistant and critical deployments.
  • Better user experience: clients remain able to connect even in offline scenarios.

Optional

  • Use SQLite for reliability and transactional support instead of JSON files.
  • Provide logging and statistics on offline cache usage and age.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions