diff --git a/frontends/main/next.config.js b/frontends/main/next.config.js index 11658fe0cc..b068b3c220 100644 --- a/frontends/main/next.config.js +++ b/frontends/main/next.config.js @@ -57,6 +57,46 @@ const nextConfig = { ] }, + async headers() { + return [ + /* This is intended to target the base HTML responses. Some are dynamically rendered, + * so Next.js instructs no-cache, however we are currently serving public content that + * is cacheable. Excludes everything with a file extension so we're matching only on routes. + */ + { + source: "/((?!.*\\.[a-zA-Z0-9]{2,4}$).*)", + headers: [ + { + key: "Cache-Control", + value: "s-maxage=120", + }, + ], + }, + + /* Images rendered with the Next.js Image component have the cache header + * set on them, but CSS background images do not. + */ + { + source: "/images/(.*)", + headers: [ + { + key: "Cache-Control", + value: "s-maxage=600", + }, + ], + }, + { + source: "/favicon.ico", + headers: [ + { + key: "Cache-Control", + value: "s-maxage=31536000", + }, + ], + }, + ] + }, + images: { remotePatterns: [ { diff --git a/frontends/main/package.json b/frontends/main/package.json index 063694aba1..bf9db484e3 100644 --- a/frontends/main/package.json +++ b/frontends/main/package.json @@ -18,7 +18,7 @@ "api": "workspace:*", "formik": "^2.4.6", "lodash": "^4.17.21", - "next": "^14.2.7", + "next": "^14.2.15", "ol-ckeditor": "0.0.0", "ol-components": "0.0.0", "ol-utilities": "0.0.0", diff --git a/yarn.lock b/yarn.lock index d467ecc53b..59eafe4da4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13690,7 +13690,7 @@ __metadata: jest: "npm:^29.7.0" jest-extended: "npm:^4.0.2" lodash: "npm:^4.17.21" - next: "npm:^14.2.7" + next: "npm:^14.2.15" ol-ckeditor: "npm:0.0.0" ol-components: "npm:0.0.0" ol-test-utilities: "npm:0.0.0" @@ -15143,7 +15143,7 @@ __metadata: languageName: node linkType: hard -"next@npm:^14.2.7": +"next@npm:^14.2.15, next@npm:^14.2.7": version: 14.2.15 resolution: "next@npm:14.2.15" dependencies: