From 8d87bebb69c48978080af7c8c236d44618e8a887 Mon Sep 17 00:00:00 2001 From: Kirill Osipov <104348270+querielo@users.noreply.github.com> Date: Mon, 29 Aug 2022 16:16:02 +0400 Subject: [PATCH] Add no-cache flag --- source/utilities/cli.ts | 2 ++ source/utilities/server.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/source/utilities/cli.ts b/source/utilities/cli.ts index 9f87deaa..9f4e0a76 100644 --- a/source/utilities/cli.ts +++ b/source/utilities/cli.ts @@ -66,6 +66,8 @@ const helpText = chalkTemplate` --no-port-switching Do not open a port other than the one specified when it\'s taken. + --no-cache Sets \`Cache-Control\` to \`no-cache, no-store, must-revalidate\` + {bold ENDPOINTS} Listen endpoints (specified by the {bold --listen} or {bold -l} options above) instruct {cyan serve} diff --git a/source/utilities/server.ts b/source/utilities/server.ts index 259d527f..d25f86d9 100644 --- a/source/utilities/server.ts +++ b/source/utilities/server.ts @@ -63,6 +63,8 @@ export const startServer = async ( if (args['--cors']) response.setHeader('Access-Control-Allow-Origin', '*'); + if (args['--no-cache']) + response.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate'); if (!args['--no-compression']) await compress(request as ExpressRequest, response as ExpressResponse);