From 21273974087f07be49cbfaeae61c63c0da9be792 Mon Sep 17 00:00:00 2001 From: sravan Date: Wed, 22 Jul 2026 22:27:37 +0530 Subject: [PATCH] perf(video): cache attachment auth so Range playback stops stuttering; strict on-demand MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause of a downloaded/streaming video buffering repeatedly: every /files Range request (a playing video fires dozens) re-ran the full attachment authorization, which scans the messages table by attachment_id (un-indexed) — a per-chunk table scan = stutter. Now the auth decision is cached per user+attachment for 60s (module-level, bounded), so range requests after the first are ~free. Also: preload='none' (nothing about a video downloads until the user taps play — only the small poster loads), per 'no auto-download'. And the buffering spinner no longer hides on canplay/loadeddata (they fire mid-buffer), so it reliably spins whenever it's buffering. build batch159. Co-Authored-By: Claude Opus 4.8 --- server/public/home.html | 6 +++--- server/static.js | 42 +++++++++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/server/public/home.html b/server/public/home.html index 449a92f..dfb4576 100644 --- a/server/public/home.html +++ b/server/public/home.html @@ -1165,7 +1165,7 @@ -