Support for Vary header
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:
- Add additional return value to
CachableResponseof[]stringthat is the list of headers in theVaryheader. E.g.["Accept-Language", "Accept-Encoding"] - Add helper to extract headers from a
http.Requestbased on theVarylist - Add normalization helpers for certain headers. See https://developer.fastly.com/reference/http/http-headers/Accept-Language/
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)