perf: fix slow homepage load times (#1025)
* perf: fix slow homepage load times with SWR caching and pool warmup
follow graph: stale-while-revalidate pattern (TTL 60min, stale at 8min)
returns cached data immediately, schedules background re-warm when stale.
removes redundant login-time cache warming from auth paths.
track listing: cache anonymous first-page discovery feed in Redis (60s TTL)
with invalidation on upload, delete, and edit.
connection pool: warm one connection at startup to eliminate cold connect
penalty on first request after deploy.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: remove stale schedule_follow_graph_warm mock from test
the import was removed from auth.py, so the test mock path no longer exists.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: narrow bare except Exception to specific types
- Redis operations: catch (RuntimeError, RedisError) instead of Exception
- DB pool warmup: catch (OSError, SQLAlchemyError) instead of Exception
- Move deferred imports in main.py to top level
- Update tests to use redis.exceptions.ConnectionError
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
authored by
zzstoatzz.io