The response header for the etag in packages/open-next/src/core/routing/cacheInterceptor.ts returns an etag of an incorrect syntax.
cacheInterceptor.ts is used when the following config is enabled:
const config = {
default: {},
dangerous: {
enableCacheInterception: true,
},
} satisfies OpenNextConfig;
Currently it returns etag: <etag_value>, while the correct syntax requires <etag_value> to be surrounded by double quotes: i.e. etag: "<etag_value>".
See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/ETag#syntax
This causes issues with Cloudfront CDN compression, as it will remove invalid etags after the compression.
See CloudFront Serve compressed files
Suggested fix
packages/open-next/src/core/routing/cacheInterceptor.ts#L61 creates the etag value as:
Instead it should be replaced with the correct etag syntax:
const etag = `"${hash(body)}"`
The suggested fix has been tested through patching locally and deployment.
Environment: sst@4.14.3, @opennextjs/aws@4.0.3, next@16.2.6
The response header for the etag in
packages/open-next/src/core/routing/cacheInterceptor.tsreturns an etag of an incorrect syntax.cacheInterceptor.tsis used when the following config is enabled:Currently it returns
etag: <etag_value>, while the correct syntax requires<etag_value>to be surrounded by double quotes: i.e.etag: "<etag_value>".See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/ETag#syntax
This causes issues with Cloudfront CDN compression, as it will remove invalid etags after the compression.
See CloudFront Serve compressed files
Suggested fix
packages/open-next/src/core/routing/cacheInterceptor.ts#L61creates the etag value as:Instead it should be replaced with the correct etag syntax:
The suggested fix has been tested through patching locally and deployment.
Environment: sst@4.14.3, @opennextjs/aws@4.0.3, next@16.2.6