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

add custom etag option to rack_response plugin #704

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

Conversation

prem-prakash
Copy link

@prem-prakash prem-prakash commented Sep 5, 2024

The rack_response plugin ETAG response header is generated based on attributes that can remain the same even if the file content has been changed.

        # Value for the "ETag" header.
        def etag
          digest = Digest::SHA256.hexdigest("#{file.shrine_class}-#{file.storage_key}-#{file.id}")

          %(W/"#{digest.byteslice(0, 32)}")
        end

This may result in unwanted response caching.

@janko
Copy link
Member

janko commented Sep 6, 2024

Looks good to me, thanks 👍🏻 I would just rename the keyword argument to :etag, as it communicates better that we're overriding the ETag. Also, would you mind updating the documentation?

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

Successfully merging this pull request may close these issues.

2 participants