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

feat(storage-s3): add cacheControlMaxAge option #10438

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

1b0t
Copy link
Contributor

@1b0t 1b0t commented Jan 8, 2025

Description

This PR introduces a new configuration option for the S3 storage plugin, allowing users to specify a cacheControlMaxAge value in seconds.

The default value is undefined which omits the Cache-Header keeping this change non-breaking.

Before changes

No Cache-Control header present on uploads beging returned.

After changes

If cacheControlMaxAge is set, Cache-Control: public, max-age={cacheControlMaxAge} is added to uploads returned.

Using plugin

s3Storage({
      ...
      cacheControlMaxAge: 31536000,
    }),
  • I have read and understand the
    CONTRIBUTING.md
    document in this repository.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • Existing test suite passes locally with my changes
  • I have made corresponding changes to the documentation

Comment on lines 50 to +52
'Accept-Ranges': String(object.AcceptRanges),
...(cacheControlMaxAge
? { 'Cache-Control': `public, max-age=${cacheControlMaxAge}` }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can replace cacheControlMaxAge with something like responseHeaders that also can be a function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea. I think it should be possible.

I tried to keep it consistent with the Vercel blob adapter for this PR.

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

Successfully merging this pull request may close these issues.

2 participants