Skip to content

stremio-jellyfin: say how long a stream answer may be cached - #124

Merged
leonardoazeredo merged 1 commit into
mainfrom
fix/stremio-jellyfin-stream-cache
Sep 22, 2026
Merged

leonardoazeredo merged 1 commit into
mainfrom
fix/stremio-jellyfin-stream-cache

Conversation

@leonardoazeredo

Copy link
Copy Markdown
Owner

Why

The addon sent no cacheMaxAge, so the Stremio client applied its own default — and a cached answer outlived the fix that corrected it.

Measured 2026-09-22: the exact-match refusal shipped at 14:00, and the same client was still playing the old fallback at 23:00 for the episodes it had cached. The client asked the addon again at 22:56, received an empty stream list, and still offered a Jellyfin stream from its cache. The same default hides an episode the drain has just delivered — the client keeps saying "no source" for something that arrived an hour ago.

The change

Every stream answer now carries cacheMaxAge: 300, refusals included.

300 and not 0: each request makes this addon scan the whole Jellyfin library (getItemByImdbId lists every Movie and Series to filter by IMDb id), so answering every navigation from scratch costs the NAS a full scan per episode opened. Five minutes caps how stale an answer can be while still absorbing a burst of re-opens.

Verification

On the NAS, at this HEAD, rebuilt from this branch:

tt19231492:99:1 -> {"streams":[],"cacheMaxAge":300}
tt19231492:2:3  -> streams: 1 | cacheMaxAge: 300

The e2e spec asserts it on both paths — the refusal (deterministic) and a resolved episode (the answer that changes when the library gains one) — so a future edit that drops the field fails rather than silently restoring the default.

One thing this cannot fix: an entry already cached by a client keeps its old lifetime until it expires. A client-side refresh is still needed once.

Not related to the drain or the arrs: this is the addon's own response header.

The addon sent no cacheMaxAge, so the Stremio client applied its own default --
and a cached answer outlived the fix that corrected it. Measured 2026-09-22: the
refusal shipped at 14:00, and the same client was still playing the old fallback
at 23:00 for the episodes it had cached. The same default would hide an episode
the drain has just delivered.

300 seconds, not 0: every request makes this addon scan the whole Jellyfin
library, so answering every navigation from scratch costs a full scan per
episode opened. Five minutes caps staleness while absorbing a burst of re-opens.
@leonardoazeredo
leonardoazeredo merged commit 7c53398 into main Sep 22, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant