Skip to content

Commit

Permalink
Fix missing or incorrect cache-control headers for Streaming server (m…
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisIsMissEm authored and ClearlyClaire committed Oct 18, 2024
1 parent f0e011f commit cd2a3ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions streaming/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

Expand Down Expand Up @@ -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');
Expand Down
2 changes: 2 additions & 0 deletions streaming/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
};
Expand Down

0 comments on commit cd2a3ba

Please sign in to comment.