Skip to content

Commit

Permalink
[Issue #2625] set max-ages for app pages (#3100)
Browse files Browse the repository at this point in the history
## Summary
Fixes #2625
  • Loading branch information
acouch authored Dec 6, 2024
1 parent 42b21ce commit 978ebbb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
42 changes: 42 additions & 0 deletions frontend/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 978ebbb

Please sign in to comment.