Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache-Control: no-transform #1252

Closed
ehmicky opened this issue Oct 19, 2024 · 3 comments
Closed

Cache-Control: no-transform #1252

ehmicky opened this issue Oct 19, 2024 · 3 comments
Assignees

Comments

@ehmicky
Copy link

ehmicky commented Oct 19, 2024

Is your feature request related to a problem? Please describe.
In @middy/http-content-encoding, if the Cache-Control: no-transform request header is set, the response should not be compressed.

Additional context
The standard.
Implementations in Cloudflare and Express.

@willfarrell willfarrell self-assigned this Oct 26, 2024
willfarrell added a commit that referenced this issue Oct 26, 2024
@willfarrell
Copy link
Member

I added in a little more. if the header exists in the request it will add to the response if the header isn't already set. then check if the response has the header set as expected before existing out early

@ehmicky
Copy link
Author

ehmicky commented Oct 27, 2024

Thanks!

Please note the current implementation does not work when the Cache-Control header contains several directives.

If the Cache-Control header in the request is no-transform, no-cache, the following condition will fail.

if (eventCacheControl === 'no-transform') {

Also, if the Cache-Control header in the response is already set, for example to no-cache, the following line will be ignored, instead of appending it as no-cache, no-transform.

response.headers['Cache-Control'] ??= 'no-transform'

@willfarrell
Copy link
Member

willfarrell commented Oct 27, 2024

Good catch! A task for tomorrow :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants