Closed khuezy closed 1 year ago
Caching happens on Cloudfront. There is no need for S3, Lambda or ApiGw to return Cache-Control information back as we are using cache policy for this route.
See
const assetsCachePolicy = new CachePolicy(this, 'NextPublicCachePolicy', {
queryStringBehavior: CacheQueryStringBehavior.all(),
enableAcceptEncodingGzip: true,
defaultTtl: Duration.hours(12),
})
Make sense, but what happens if you set a different cache control data on individual items in the bucket? Will it respect those cache-controls, or will it just use the assetsCachePolicy
?
The image optimization reads the cache control from the bucket:
if (response.CacheControl) {
res.setHeader('Cache-Control', response.CacheControl)
}
Bucket's cache-control is ignored. I cannot really see use of setting cache-control for individual items, could you provide some business scenario when this might be needed? I'm striving for simple out-of-the-box solution, not to cover all edge cases.
Cache Control headers are currently set at the internal
res
level, the lambda itself needs to pass the headers back to CF/Browser.