diff --git a/API.md b/API.md index c5605e10..499a20fb 100644 --- a/API.md +++ b/API.md @@ -2713,7 +2713,7 @@ public readonly prune: boolean; ``` - *Type:* boolean -- *Default:* true +- *Default:* false If `true`, then delete old objects in `destinationBucket`/`destinationKeyPrefix` **after** uploading new objects. Only applies if `zip` is `false`. @@ -2721,6 +2721,9 @@ Old objects are determined by listing objects in bucket before creating new objects and finding the objects that aren't in the new objects. +Note, if this is set to true then clients who have old HTML files (browser tabs opened before deployment) +will reference JS, CSS files that do not exist in S3 reslting in 404s. + --- ##### `putConfig`Optional @@ -7520,7 +7523,7 @@ public readonly prune: boolean; ``` - *Type:* boolean -- *Default:* true +- *Default:* false If `true`, then delete old objects in `destinationBucket`/`destinationKeyPrefix` **after** uploading new objects. @@ -7529,6 +7532,9 @@ Old objects are determined by listing objects in bucket before creating new objects and finding the objects that aren't in the new objects. +Note, if this is set to true then clients who have old HTML files (browser tabs opened before deployment) +will reference JS, CSS files that do not exist in S3 reslting in 404s. + --- ##### `putConfig`Optional diff --git a/src/NextjsBucketDeployment.ts b/src/NextjsBucketDeployment.ts index e2569f36..577abd7b 100644 --- a/src/NextjsBucketDeployment.ts +++ b/src/NextjsBucketDeployment.ts @@ -29,7 +29,10 @@ export interface NextjsBucketDeploymentProps { * Old objects are determined by listing objects * in bucket before creating new objects and finding the objects that aren't in * the new objects. - * @default true + * + * Note, if this is set to true then clients who have old HTML files (browser tabs opened before deployment) + * will reference JS, CSS files that do not exist in S3 reslting in 404s. + * @default false */ readonly prune?: boolean | undefined; /** @@ -143,7 +146,7 @@ export class NextjsBucketDeployment extends Construct { destinationBucketName: this.props.destinationBucket.bucketName, destinationKeyPrefix: this.props.destinationKeyPrefix, putConfig: this.props.putConfig, - prune: this.props.prune, + prune: this.props.prune ?? false, substitutionConfig: this.props.substitutionConfig, zip: this.props.zip, }; diff --git a/src/NextjsStaticAssets.ts b/src/NextjsStaticAssets.ts index eecefd97..880badb9 100644 --- a/src/NextjsStaticAssets.ts +++ b/src/NextjsStaticAssets.ts @@ -127,7 +127,7 @@ export class NextjsStaticAssets extends Construct { // only put env vars that are placeholders in custom resource properties // to be replaced. other env vars were injected at build time. substitutionConfig: NextjsBucketDeployment.getSubstitutionConfig(this.buildEnvVars), - prune: this.props.prune === false ? false : true, // default to true + prune: this.props.prune, // defaults to false putConfig: { [allFiles]: { CacheControl: 'public, max-age=0, must-revalidate', diff --git a/src/generated-structs/OptionalNextjsBucketDeploymentProps.ts b/src/generated-structs/OptionalNextjsBucketDeploymentProps.ts index 39f0ca42..d0a6ab02 100644 --- a/src/generated-structs/OptionalNextjsBucketDeploymentProps.ts +++ b/src/generated-structs/OptionalNextjsBucketDeploymentProps.ts @@ -38,7 +38,10 @@ export interface OptionalNextjsBucketDeploymentProps { * Old objects are determined by listing objects * in bucket before creating new objects and finding the objects that aren't in * the new objects. - * @default true + * + * Note, if this is set to true then clients who have old HTML files (browser tabs opened before deployment) + * will reference JS, CSS files that do not exist in S3 reslting in 404s. + * @default false * @stability stable */ readonly prune?: boolean;