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

Support for Vary header #25

Open
bofia opened this issue Feb 10, 2022 · 1 comment
Open

Support for Vary header #25

bofia opened this issue Feb 10, 2022 · 1 comment

Comments

@bofia
Copy link

bofia commented Feb 10, 2022

The Vary header can change the cacheability of a response. This library could add some helpers to account for it. A dev would probably want to create a cache key based on the headers in Vary

Proposal:

  1. Add additional return value to CachableResponse of []string that is the list of headers in the Vary header. E.g. ["Accept-Language", "Accept-Encoding"]
  2. Add helper to extract headers from a http.Request based on the Vary list
  3. Add normalization helpers for certain headers. See https://developer.fastly.com/reference/http/http-headers/Accept-Language/
@pquerna
Copy link
Owner

pquerna commented Feb 11, 2022

This would be a great pull request, and I like how the proposal is split into 3 separate isolated changes.

I assume for #1 you would use the normalization function right? Just thinking out loud - Does it make sense to have a "type" for the normalized vary header to avoid extra parsing in #2? String might be fine enough.

Is there a 4th function here, a "cache keys" function, that could return a map[string]string of cache keys or a similar interface? (i think actually hashing the keys should be done outside of this library - many different ways people might want to do that)

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

No branches or pull requests

2 participants