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
{{ message }}
This repository was archived by the owner on Jan 28, 2025. It is now read-only.
The example above adds headers that can be forwarded to the SSR lambda, and sets the _ttl_ for api lambdas.
132
+
The example above adds headers that can be forwarded to the SSR lambda, and sets the `ttl` for api lambdas.
133
133
134
134
### Custom domain name
135
135
@@ -226,31 +226,33 @@ myNextApplication:
226
226
apiLambda: fooApiLambda
227
227
```
228
228
229
-
### Public asset configuration
229
+
### Public directory caching
230
230
231
-
By default, assets under `/public` or `/static` don't have cache control applied. However, you can overwrite this by setting `publicAssetCache`.
232
-
Simply setting it to `true` will use the default of setting `Cache-Control=public, max-age=31536000, must-revalidate` on the following image formats: `gif|jpe?g|jp2|tiff|png|webp|bmp|svg`:
231
+
By default, common image formats(`gif|jpe?g|jp2|tiff|png|webp|bmp|svg|ico`) under `/public` or `/static` folders
232
+
have a one-year `Cache-Control` policy applied(`public, max-age=31536000, must-revalidate`).
233
+
234
+
You may customize either the `Cache-Control` header `value` and the regex of which files to `test`, with `publicDirectoryCache`:
233
235
234
236
```yaml
235
237
myNextApplication:
236
238
component: serverless-next.js
237
239
inputs:
238
-
publicAssetCache: true
240
+
publicDirectoryCache:
241
+
value: public, max-age=604800
242
+
test: /\.(gif|jpe?g|png|txt|xml)$/i
239
243
```
240
244
241
-
To customize either or both, you can:
245
+
`value`must be a valid `Cache-Control` policy and `test` must be a valid `regex` of the types of files you wish to test.
246
+
247
+
If you don't want browsers to cache assets from the public directory, you can disable this:
242
248
243
249
```yaml
244
250
myNextApplication:
245
251
component: serverless-next.js
246
252
inputs:
247
-
publicAssetCache:
248
-
value: public, max-age=604800
249
-
test: /\.(gif|jpe?g|png|txt|xml)$/i
253
+
publicDirectoryCache: false
250
254
```
251
255
252
-
`value`must be a valid `Cache-Control` policy and `test` must be a valid regex of the types of files you wish to test.
253
-
254
256
### Architecture
255
257
256
258

@@ -273,23 +275,23 @@ The fourth cache behaviour handles next API requests `api/*`.
| cloudfront | `object` | `{}` | Sets cloudfront cache options for both SSR and api lambdas. Options are defined in the [aws-cloudfront component](https://github.com/serverless-components/aws-cloudfront) | |
279
-
| domain | `Array` | `null` | For example `['admin', 'portal.com']` |
280
-
| bucketName | `string` | `null` | Custom bucket name where static assets are stored. By default is autogenerated. |
281
-
| nextConfigDir | `string` | `./` | Directory where your application `next.config.js` file is. This input is useful when the `serverless.yml` is not in the same directory as the next app. <br>**Note:** `nextConfigDir` should be set if `next.config.js` `distDir` is used |
282
-
| nextStaticDir | `string` | `./` | If your `static` or `public` directory is not a direct child of `nextConfigDir` this is needed |
283
-
| memory | `number\|object` | `512` | When assigned a number, both the default and api lambdas will assigned memory of that value. When assigned to an object, values for the default and api lambdas can be separately defined | |
284
-
| timeout | `number\|object` | `10` | Same as above |
285
-
| name | `string\|object` | / | When assigned a string, both the default and api lambdas will assigned name of that value. When assigned to an object, values for the default and api lambdas can be separately defined |
286
-
| publicAssetCache | `boolean\|object` | `false` | Sets `Cache-Control` policy on files under the `/public`/`/static` folders. When assigned `true`, a default caching is applied to all images, this can be customized by assigning an object, with a `test` regex and/or a different `value` for the caching policy. |
287
-
| build | `boolean\|object` | `true` | When true builds and deploys app, when false assume the app has been built and uses the `.next` `.serverless_nextjs` directories in `nextConfigDir` to deploy. If an object is passed `build` allows for overriding what script gets called and with what arguments. |
| cloudfront | `object` | `{}` | Sets cloudfront cache options for both SSR and api lambdas. Options are defined in the [aws-cloudfront component](https://github.com/serverless-components/aws-cloudfront) |
281
+
| domain | `Array` | `null` | For example `['admin', 'portal.com']` |
282
+
| bucketName | `string` | `null` | Custom bucket name where static assets are stored. By default is autogenerated. |
283
+
| nextConfigDir | `string` | `./` | Directory where your application `next.config.js` file is. This input is useful when the `serverless.yml` is not in the same directory as the next app. <br>**Note:** `nextConfigDir` should be set if `next.config.js` `distDir` is used |
284
+
| nextStaticDir | `string` | `./` | If your `static` or `public` directory is not a direct child of `nextConfigDir` this is needed |
285
+
| memory | `number\|object` | `512` | When assigned a number, both the default and api lambdas will assigned memory of that value. When assigned to an object, values for the default and api lambdas can be separately defined |
286
+
| timeout | `number\|object` | `10` | Same as above |
287
+
| name | `string\|object` | / | When assigned a string, both the default and api lambdas will assigned name of that value. When assigned to an object, values for the default and api lambdas can be separately defined |
288
+
| publicDirectoryCache | `boolean\|object` | `true` | Customize the `public`/`static` folder asset caching policy. Assigning an object with `value` and/or `test` lets you customize the caching policy and the types of files being cached. Assigning false disables caching |
289
+
| build | `boolean\|object` | `true` | When true builds and deploys app, when false assume the app has been built and uses the `.next` `.serverless_nextjs` directories in `nextConfigDir` to deploy. If an object is passed `build` allows for overriding what script gets called and with what arguments. |
0 commit comments