Created
June 17, 2021 16:15
-
-
Save iDVB/fbcf30de3ff37e9a450824cf679b9e54 to your computer and use it in GitHub Desktop.
Gatsby Cache-Control in CDK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const deployment1 = new s3deploy.BucketDeployment(this, 'BucketDeployment1', { | |
sources: [ | |
s3deploy.Source.asset(props.siteAssetsPath, { | |
ignoreMode: cdk.IgnoreMode.GIT, | |
exclude: ['*.*', '!*.js', '!*.css', 'sw.js', '!static/**', '_redirects'], | |
}), | |
], | |
memoryLimit: 512, | |
cacheControl: [s3deploy.CacheControl.fromString('public,max-age=31536000,immutable')], | |
destinationBucket: primaryBucket, | |
prune: true, | |
}) | |
const deployment2 = new s3deploy.BucketDeployment(this, 'BucketDeployment2', { | |
sources: [ | |
s3deploy.Source.asset(props.siteAssetsPath, { | |
ignoreMode: cdk.IgnoreMode.GIT, | |
exclude: [ | |
'*.*', | |
'!*.html', | |
'!page-data/**/*.json', | |
'!sw.js', | |
'!robots.txt', | |
'!sitemap/**', | |
'!_redirects', | |
], | |
}), | |
], | |
memoryLimit: 512, | |
cacheControl: [s3deploy.CacheControl.fromString('public,max-age=0,must-revalidate')], | |
destinationBucket: primaryBucket, | |
prune: false, | |
}) | |
const deployment3 = new s3deploy.BucketDeployment(this, 'BucketDeployment3', { | |
sources: [ | |
s3deploy.Source.asset(props.siteAssetsPath, { | |
ignoreMode: cdk.IgnoreMode.GIT, | |
exclude: [ | |
'*.html', | |
'page-data/**/*.json', | |
'*.js', | |
'*.css', | |
'static/**', | |
'robots.txt', | |
'sitemap/**', | |
'_redirects', | |
], | |
}), | |
], | |
memoryLimit: 512, | |
destinationBucket: primaryBucket, | |
prune: false, | |
}) | |
deployment3.node.addDependency(deployment2) | |
deployment3.node.addDependency(deployment1) | |
deployment2.node.addDependency(deployment1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment