Skip to content

Commit

Permalink
feat: Support configuration of cache control
Browse files Browse the repository at this point in the history
  • Loading branch information
jessieweiyi committed May 3, 2024
1 parent 5f1f30e commit abd3371
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/threat-composer-infra/cdk.context.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"certificateProd": "",
"hostZoneProd": "",
"hostZoneNameProd": "",
"lambdaEdgeProd": ""
"lambdaEdgeProd": "",
"cacheControlNoCache": "true"
}
6 changes: 4 additions & 2 deletions packages/threat-composer-infra/src/application-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -109,7 +111,7 @@ export class ApplicationStack extends Stack {
accessControlAllowHeaders: ['*'],
originOverride: true,
},
customHeadersBehavior: {
customHeadersBehavior: cacheControlNoCache ? {
customHeaders: [
{ header: 'pragma', value: 'no-cache', override: true },
{
Expand All @@ -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.
Expand Down

0 comments on commit abd3371

Please sign in to comment.