diff --git a/packages/threat-composer-infra/cdk.context.json b/packages/threat-composer-infra/cdk.context.json index 12a97c6a..5118105d 100644 --- a/packages/threat-composer-infra/cdk.context.json +++ b/packages/threat-composer-infra/cdk.context.json @@ -16,5 +16,6 @@ "certificateProd": "", "hostZoneProd": "", "hostZoneNameProd": "", - "lambdaEdgeProd": "" + "lambdaEdgeProd": "", + "cacheControlNoCache": "true" } \ No newline at end of file diff --git a/packages/threat-composer-infra/src/application-stack.ts b/packages/threat-composer-infra/src/application-stack.ts index 7f7ca4dc..c37da05d 100644 --- a/packages/threat-composer-infra/src/application-stack.ts +++ b/packages/threat-composer-infra/src/application-stack.ts @@ -97,6 +97,8 @@ export class ApplicationStack extends Stack { 'contentSecurityPolicyOverride', ) as string; + const cacheControlNoCache = (this.node.tryGetContext('cacheControlNoCache') as string) !== 'false'; + const responseHeadersPolicy = new ResponseHeadersPolicy( this, 'ResourceHeadersPolicy', @@ -109,7 +111,7 @@ export class ApplicationStack extends Stack { accessControlAllowHeaders: ['*'], originOverride: true, }, - customHeadersBehavior: { + customHeadersBehavior: cacheControlNoCache ? { customHeaders: [ { header: 'pragma', value: 'no-cache', override: true }, { @@ -118,7 +120,7 @@ export class ApplicationStack extends Stack { override: true, }, ], - }, + } : undefined, securityHeadersBehavior: { // A default content security policy is present in the index.html file to cater for github page hosting. // Here allow users to override to cater for specific use cases.