fix: do not return cache headers when noCache is set

This commit is contained in:
WebStreamr 2025-09-16 12:07:40 +00:00
parent 261897c699
commit d06c2934a8
No known key found for this signature in database

View file

@ -3,7 +3,7 @@ import { Request, Response, Router } from 'express';
import { ContentType } from 'stremio-addon-sdk';
import winston from 'winston';
import { Source } from '../source';
import { contextFromRequestAndResponse, envIsProd, Id, ImdbId, StreamResolver, TmdbId } from '../utils';
import { contextFromRequestAndResponse, envIsProd, Id, ImdbId, noCache, StreamResolver, TmdbId } from '../utils';
export class StreamController {
public readonly router: Router;
@ -53,7 +53,9 @@ export class StreamController {
await mutex.runExclusive(async () => {
const { streams, ttl } = await this.streamResolver.resolve(ctx, sources, type, id);
if (ttl && envIsProd()) {
if (noCache(ctx.config)) {
res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0');
} else if (ttl && envIsProd()) {
res.setHeader('Cache-Control', `max-age=${Math.floor(ttl / 1000)}, public`);
}