Choose a caching strategy
masterYou can specify a :strategy to change how cache keys are generated.
Faraday::HttpCache::Strategies::ByUrl(Default): Uses URL + HTTP method. Stores an array of request + response for each key.Faraday::HttpCache::Strategies::ByVary: Uses headers from theVaryheader to generate keys. This is ideal for caching private responses with the same URL but different results for different users (e.g.,/user).
To implement a custom strategy, subclass Faraday::HttpCache::Strategies::BaseStrategy and implement #write, #read, and #delete.
client = Faraday.new do |builder|
builder.use :http_cache, store: Rails.cache, strategy: Faraday::HttpCache::Strategies::ByVary
builder.adapter Faraday.default_adapter
end