fix: do not return cache headers when noCache is set
This commit is contained in:
parent
261897c699
commit
d06c2934a8
1 changed files with 4 additions and 2 deletions
|
|
@ -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`);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue