From d201854a78aeae7f7b4c2ffd1052950031fcf68c Mon Sep 17 00:00:00 2001 From: Trevor Sharp Date: Tue, 16 Apr 2024 21:37:47 +0000 Subject: [PATCH] Add back cache control headers for CDN caching --- src/app/[username]/feed/route.ts | 2 +- src/app/videos/[videoId]/route.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/[username]/feed/route.ts b/src/app/[username]/feed/route.ts index 822957d..39cc203 100644 --- a/src/app/[username]/feed/route.ts +++ b/src/app/[username]/feed/route.ts @@ -15,7 +15,7 @@ const GET = async (request: Request, { params }: { params: { username: string } const rssFeed = await getRssFeed(username, hostname, quality); - return new NextResponse(rssFeed); + return new NextResponse(rssFeed, { headers: { "Cache-Control": "s-maxage=300" } }); } catch (errorMessage) { return new NextResponse((errorMessage as string | undefined) ?? "Unexpected Error", { status: 500, diff --git a/src/app/videos/[videoId]/route.ts b/src/app/videos/[videoId]/route.ts index bf47a52..9e01dfd 100644 --- a/src/app/videos/[videoId]/route.ts +++ b/src/app/videos/[videoId]/route.ts @@ -13,7 +13,9 @@ const GET = async (request: Request, { params }: { params: { videoId: string } } const m3u8 = await getStream(videoId, quality); - return new NextResponse(m3u8, { headers: { "Content-Type": "application/x-mpegURL" } }); + return new NextResponse(m3u8, { + headers: { "Cache-Control": "s-maxage=600", "Content-Type": "application/x-mpegURL" }, + }); } catch (errorMessage) { return new NextResponse((errorMessage as string | undefined) ?? "Unexpected Error", { status: 500,