Skip to content

Commit 500ec83

Browse files
styfleunstubbable
authored andcommitted
fetch(next/image): reduce maximumResponseBody from 300MB to 50MB (#88588)
Based on our metrics, the P99.9 for a source image is 47 MB so we can adjust the default setting to be much lower (by changing from from 300 MB to 50 MB) in favor of reducing memory.
1 parent 1caaca3 commit 500ec83

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

docs/01-app/03-api-reference/02-components/image.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -839,22 +839,22 @@ module.exports = {
839839

840840
#### `maximumResponseBody`
841841

842-
The default image optimization loader will fetch source images up to 300 MB in size.
842+
The default image optimization loader will fetch source images up to 50 MB in size.
843843

844844
```js filename="next.config.js"
845845
module.exports = {
846846
images: {
847-
maximumResponseBody: 300_000_000,
847+
maximumResponseBody: 50_000_000,
848848
},
849849
}
850850
```
851851

852-
If you know all your source images are small, you can protect memory constrained servers by reducing this to a smaller value such as 50 MB.
852+
If you know all your source images are small, you can protect memory constrained servers by reducing this to a smaller value such as 5 MB.
853853

854854
```js filename="next.config.js"
855855
module.exports = {
856856
images: {
857-
maximumResponseBody: 50_000_000,
857+
maximumResponseBody: 5_000_000,
858858
},
859859
}
860860
```

packages/next/src/shared/lib/image-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export const imageConfigDefault: ImageConfigComplete = {
150150
minimumCacheTTL: 14400, // 4 hours
151151
formats: ['image/webp'],
152152
maximumRedirects: 3,
153-
maximumResponseBody: 300_000_000, // 300MB
153+
maximumResponseBody: 50_000_000, // 50 MB
154154
dangerouslyAllowLocalIP: false,
155155
dangerouslyAllowSVG: false,
156156
contentSecurityPolicy: `script-src 'none'; frame-src 'none'; sandbox;`,

test/integration/next-image-new/app-dir-localpatterns/test/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function runTests(mode: 'dev' | 'server') {
9898
},
9999
],
100100
maximumRedirects: 3,
101-
maximumResponseBody: 300000000,
101+
maximumResponseBody: 50000000,
102102
minimumCacheTTL: 14400,
103103
path: '/_next/image',
104104
qualities: [75],

test/integration/next-image-new/app-dir-qualities/test/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function runTests(mode: 'dev' | 'server') {
110110
},
111111
],
112112
maximumRedirects: 3,
113-
maximumResponseBody: 300000000,
113+
maximumResponseBody: 50000000,
114114
minimumCacheTTL: 14400,
115115
path: '/_next/image',
116116
qualities: [42, 69, 88],

test/integration/next-image-new/app-dir/test/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1796,7 +1796,7 @@ function runTests(mode: 'dev' | 'server') {
17961796
},
17971797
],
17981798
maximumRedirects: 3,
1799-
maximumResponseBody: 300000000,
1799+
maximumResponseBody: 50000000,
18001800
minimumCacheTTL: 14400,
18011801
path: '/_next/image',
18021802
qualities: [75],

test/integration/next-image-new/unicode/test/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function runTests(mode: 'server' | 'dev') {
103103
},
104104
],
105105
maximumRedirects: 3,
106-
maximumResponseBody: 300000000,
106+
maximumResponseBody: 50000000,
107107
minimumCacheTTL: 14400,
108108
path: '/_next/image',
109109
qualities: [75],

test/integration/next-image-new/unoptimized/test/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function runTests(url: string, mode: 'dev' | 'server') {
118118
},
119119
],
120120
maximumRedirects: 3,
121-
maximumResponseBody: 300000000,
121+
maximumResponseBody: 50000000,
122122
minimumCacheTTL: 14400,
123123
path: '/_next/image',
124124
qualities: [75],

test/unit/image-optimizer/fetch-external-image.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('fetchExternalImage', () => {
1919
const error = await fetchExternalImage(
2020
'http://example.com/no-body.jpg',
2121
false,
22-
300_000_000
22+
50_000_000
2323
).catch((e) => e)
2424

2525
expect(error).toBeInstanceOf(ImageError)

0 commit comments

Comments
 (0)