@netlify/plugin-nextjs 5.15.4 → 5.15.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -86,7 +86,7 @@ var pipeline = (0, import_util.promisify)(import_stream.pipeline);
86
86
 
87
87
  // package.json
88
88
  var name = "@netlify/plugin-nextjs";
89
- var version = "5.15.4";
89
+ var version = "5.15.5";
90
90
 
91
91
  // src/run/handlers/tags-handler.cts
92
92
  var import_storage = require("../storage/storage.cjs");
@@ -148,7 +148,7 @@ function setCacheControlFromRequestContext(headers, revalidate) {
148
148
  headers.set("netlify-cdn-cache-control", cdnCacheControl);
149
149
  }
150
150
  var setCacheControlHeaders = ({ headers, status }, request, requestContext) => {
151
- if (typeof requestContext.routeHandlerRevalidate !== "undefined" && ["GET", "HEAD"].includes(request.method) && !headers.has("cdn-cache-control") && !headers.has("netlify-cdn-cache-control")) {
151
+ if (typeof requestContext.routeHandlerRevalidate !== "undefined" && ["GET", "HEAD"].includes(request.method) && (headers.has("x-nextjs-cache") || !headers.has("cdn-cache-control") && !headers.has("netlify-cdn-cache-control"))) {
152
152
  setCacheControlFromRequestContext(headers, requestContext.routeHandlerRevalidate);
153
153
  return;
154
154
  }
@@ -164,21 +164,23 @@ var setCacheControlHeaders = ({ headers, status }, request, requestContext) => {
164
164
  }
165
165
  }
166
166
  const cacheControl = headers.get("cache-control");
167
- if (cacheControl !== null && ["GET", "HEAD"].includes(request.method) && !headers.has("cdn-cache-control") && !headers.has("netlify-cdn-cache-control")) {
167
+ if (cacheControl !== null && ["GET", "HEAD"].includes(request.method) && (headers.has("x-nextjs-cache") || !headers.has("cdn-cache-control") && !headers.has("netlify-cdn-cache-control"))) {
168
168
  const browserCacheControl = omitHeaderValues(cacheControl, [
169
169
  "s-maxage",
170
170
  "stale-while-revalidate"
171
171
  ]);
172
+ const cacheControlForCdnFromNext = headers.get("cdn-cache-control") ?? cacheControl;
172
173
  const cdnCacheControl = (
173
174
  // if we are serving already stale response, instruct edge to not attempt to cache that response
174
175
  headers.get("x-nextjs-cache") === "STALE" ? "public, max-age=0, must-revalidate, durable" : [
175
- ...getHeaderValueArray(cacheControl).map(
176
+ ...getHeaderValueArray(cacheControlForCdnFromNext).map(
176
177
  (value) => value === "stale-while-revalidate" ? "stale-while-revalidate=31536000" : value
177
178
  ),
178
179
  "durable"
179
180
  ].join(", ")
180
181
  );
181
182
  headers.set("cache-control", browserCacheControl || "public, max-age=0, must-revalidate");
183
+ headers.delete("cdn-cache-control");
182
184
  headers.set("netlify-cdn-cache-control", cdnCacheControl);
183
185
  return;
184
186
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/plugin-nextjs",
3
- "version": "5.15.4",
3
+ "version": "5.15.5",
4
4
  "description": "Run Next.js seamlessly on Netlify",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",