You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-1
Original file line number
Diff line number
Diff line change
@@ -69,7 +69,8 @@ See [below](#other-servers) for an example of use with fastify.
69
69
|**[`mimeTypeDefault`](#mimetypedefault)**|`string`|`undefined`| Allows to register a default mime type when we can't determine the content type. |
70
70
|**[`etag`](#tag)**|`boolean\| "weak"\| "strong"`|`undefined`| Enable or disable etag generation. |
71
71
|**[`lastModified`](#lastmodified)**|`boolean`|`undefined`| Enable or disable `Last-Modified` header. Uses the file system's last modified value. |
72
-
|**[`cacheControl`](#cachecontrol)**|`boolean\|number\|string\|Object`|`undefined`| Enable or disable `Last-Modified` header. Uses the file system's last modified value. |
72
+
|**[`cacheControl`](#cachecontrol)**|`boolean\|number\|string\|Object`|`undefined`| Enable or disable setting `Cache-Control` response header. |
73
+
|**[`cacheImmutable`](#cacheimmutable)**|`boolean\`|`undefined`| Enable or disable setting `Cache-Control: public, max-age=31536000, immutable` response header for immutable assets. |
73
74
|**[`publicPath`](#publicpath)**|`string`|`undefined`| The public path that the middleware is bound to. |
74
75
|**[`stats`](#stats)**|`boolean\|string\|Object`|`stats` (from a configuration) | Stats options object or preset name. |
75
76
|**[`serverSideRender`](#serversiderender)**|`boolean`|`undefined`| Instructs the module to enable or disable the server-side rendering mode. |
@@ -202,6 +203,15 @@ Depending on the setting, the following headers will be generated:
202
203
203
204
Enable or disable setting `Cache-Control` response header.
204
205
206
+
### cacheImmutable
207
+
208
+
Type: `Boolean`
209
+
Default: `undefined`
210
+
211
+
Enable or disable setting `Cache-Control: public, max-age=31536000, immutable` response header for immutable assets (i.e. asset with a hash like `image.a4c12bde.jpg`).
212
+
Immutable assets are assets that have their hash in the file name therefore they can be cached, because if you change their contents the file name will be changed.
213
+
Take preference over the `cacheControl` option if the asset was defined as immutable.
Copy file name to clipboardExpand all lines: src/options.json
+5
Original file line number
Diff line number
Diff line change
@@ -167,6 +167,11 @@
167
167
"additionalProperties": false
168
168
}
169
169
]
170
+
},
171
+
"cacheImmutable": {
172
+
"description": "Enable or disable setting `Cache-Control: public, max-age=31536000, immutable` response header for immutable assets (i.e. asset with a hash in file name like `image.a4c12bde.jpg`).",
Copy file name to clipboardExpand all lines: test/__snapshots__/validation-options.test.js.snap.webpack5
+20
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,25 @@
1
1
// Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
3
+
exports[`validation should throw an error on the "cacheControl" option with "{"unknown":true,"maxAge":10000}" value 1`] = `
4
+
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
5
+
- options.cacheControl has an unknown property 'unknown'. These properties are valid:
6
+
object { maxAge?, immutable? }"
7
+
`;
8
+
9
+
exports[`validation should throw an error on the "cacheImmutable" option with "0" value 1`] = `
10
+
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
11
+
- options.cacheImmutable should be a boolean.
12
+
-> Enable or disable setting \`Cache-Control: public, max-age=31536000, immutable\` response header for immutable assets (i.e. asset with a hash in file name like \`image.a4c12bde.jpg\`).
13
+
-> Read more at https://github.com/webpack/webpack-dev-middleware#cacheimmutable"
14
+
`;
15
+
16
+
exports[`validation should throw an error on the "cacheImmutable" option with "foo" value 1`] = `
17
+
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
18
+
- options.cacheImmutable should be a boolean.
19
+
-> Enable or disable setting \`Cache-Control: public, max-age=31536000, immutable\` response header for immutable assets (i.e. asset with a hash in file name like \`image.a4c12bde.jpg\`).
20
+
-> Read more at https://github.com/webpack/webpack-dev-middleware#cacheimmutable"
21
+
`;
22
+
3
23
exports[`validation should throw an error on the "etag" option with "0" value 1`] = `
4
24
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
0 commit comments