From cd2a3bac796e05228101c9ea8540202de4211b2c Mon Sep 17 00:00:00 2001 From: Emelia Smith <ThisIsMissEm@users.noreply.github.com> Date: Thu, 17 Oct 2024 10:17:18 +0200 Subject: [PATCH] Fix missing or incorrect cache-control headers for Streaming server (#32551) --- streaming/index.js | 4 ++-- streaming/metrics.js | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/streaming/index.js b/streaming/index.js index 48ed56b29b..3e362f1860 100644 --- a/streaming/index.js +++ b/streaming/index.js @@ -235,7 +235,7 @@ const startServer = async () => { app.get('/favicon.ico', (_req, res) => res.status(404).end()); app.get('/api/v1/streaming/health', (_req, res) => { - res.writeHead(200, { 'Content-Type': 'text/plain' }); + res.writeHead(200, { 'Content-Type': 'text/plain', 'Cache-Control': 'private, no-store' }); res.end('OK'); }); @@ -858,7 +858,7 @@ const startServer = async () => { } res.setHeader('Content-Type', 'text/event-stream'); - res.setHeader('Cache-Control', 'no-store'); + res.setHeader('Cache-Control', 'private, no-store'); res.setHeader('Transfer-Encoding', 'chunked'); res.write(':)\n'); diff --git a/streaming/metrics.js b/streaming/metrics.js index bb6bce3f3c..263339a1ca 100644 --- a/streaming/metrics.js +++ b/streaming/metrics.js @@ -98,9 +98,11 @@ export function setupMetrics(channels, pgPool) { const requestHandler = (req, res) => { metrics.register.metrics().then((output) => { res.set('Content-Type', metrics.register.contentType); + res.set('Cache-Control', 'private, no-store'); res.end(output); }).catch((err) => { req.log.error(err, "Error collecting metrics"); + res.set('Cache-Control', 'private, no-store'); res.status(500).end(); }); };