Race the CDN and the proxy, for thumbnails and for playback
A thumbnail used to try the provider and only ask /api/image once that had failed, so every hotlink-blocked host cost a wasted request per card before anything appeared. Both routes now go out together for the first thumbnail of a host, and the rest of the batch waits on that one answer rather than each rediscovering it. Speed decides which image is shown; capability decides what the host is remembered as, since the proxy tends to win first contact merely for being same-origin -- pinning a host to it over that would push a whole page of thumbnails through our own server. Playback asks the same question, but per video and at play time: one provider can spread its media over several CDNs, so there is nothing useful to pre-compute, and the old per-card probe answered for whichever card happened to scroll past. The direct route is now tested alongside the proxied playback and takes over if it answers before a frame is decoded. Whatever loses is cancelled -- the token guards stopped stale callbacks but left their requests running, so the losing route kept pulling bytes and the server kept an upstream connection open for them. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QBDkEXP4htyXTCZUwMLphd
This commit is contained in:
@@ -392,7 +392,7 @@ App.favorites = App.favorites || {};
|
||||
<button class="video-menu-item" type="button" data-action="download" role="menuitem">Download</button>
|
||||
</div>
|
||||
<div class="video-thumb">
|
||||
<img src="${item.thumb}" alt="${item.title}" loading="lazy" decoding="async">
|
||||
<img alt="${item.title}" loading="lazy" decoding="async">
|
||||
<div class="video-loading" aria-hidden="true">
|
||||
<div class="video-loading-spinner"></div>
|
||||
</div>
|
||||
@@ -404,8 +404,8 @@ App.favorites = App.favorites || {};
|
||||
</div>
|
||||
`;
|
||||
const thumb = card.querySelector('img');
|
||||
if (App.videos && typeof App.videos.attachNoReferrerRetry === 'function') {
|
||||
App.videos.attachNoReferrerRetry(thumb);
|
||||
if (App.videos && typeof App.videos.attachThumbnail === 'function') {
|
||||
App.videos.attachThumbnail(thumb, item.thumb);
|
||||
}
|
||||
card.onclick = () => {
|
||||
if (card.classList.contains('is-loading')) return;
|
||||
|
||||
Reference in New Issue
Block a user