diff --git a/frontend/next.config.js b/frontend/next.config.js index 3bdbe1a25..11096a376 100644 --- a/frontend/next.config.js +++ b/frontend/next.config.js @@ -16,6 +16,48 @@ const appSassOptions = sassOptions(basePath); /** @type {import('next').NextConfig} */ const nextConfig = { + async headers() { + return [ + { + // static pages are stored for 6 hours, refreshed in the background for + // up to 10 minutes, and up to 12 hours if there is an error + source: "/:path*", + headers: [ + { + key: "Cache-Control", + value: + "s-maxage=21600, stale-while-revalidate=600, stale-if-error=43200", + }, + { + key: "Vary", + value: "Accept-Language", + }, + ], + }, + // search page is stored 1 hour, stale 1 min, stale if error 5 mins + { + source: "/search", + headers: [ + { + key: "Cache-Control", + value: + "s-maxage=3600, stale-while-revalidate=60, stale-if-error=300", + }, + ], + }, + // opportunity pages are stored 10 mins, stale 1 min, stale if error 5 mins + { + source: "/opportunity/:id(\\d{1,})", + headers: [ + { + key: "Cache-Control", + value: + "s-maxage=600, stale-while-revalidate=60, stale-if-error=300", + }, + ], + }, + ]; + }, basePath, reactStrictMode: true, // Output only the necessary files for a deployment, excluding irrelevant node_modules diff --git a/frontend/package.json b/frontend/package.json index 19f9ba1fa..0d0889bc5 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -6,7 +6,7 @@ "node": ">=20.0.0" }, "scripts": { - "all-checks": "npm run test && npm run lint && npm run ts:check && npm run build", + "all-checks": "npm run lint && npm run ts:check && npm run test && npm run build", "build": "next build", "dev": "NEW_RELIC_ENABLED=false next dev", "dev:nr": "NODE_OPTIONS='-r @newrelic/next' next dev",