sourcelevel / faraday-http-cache

A Faraday middleware that respects HTTP cache
Other
343 stars 86 forks source link

Add ability to use headers from `Vary` as part of cache keys #127

Closed skryukov closed 2 years ago

skryukov commented 2 years ago

The initial problem: we use GitHub API and to save on API limits we want to use HTTP caching, but with the current Faraday::HttpCache::Storage implementation (one cache key per URL) caching of GitHub API endpoints like https://api.github.com/user is impossible since for every request we are fetching an array of all requests for all our users. Limiting the number of cached entries per key from #121 is also not an option in this case.

So, the only way to cache GitHub API for us is implementing different storage strategy. That is what this PR is about.

This PR Introduced a new strategy option to support different cache storage strategies:

This PR also:

This PR is a successor for #122 Related #112

garaujodev commented 2 years ago

Thanks for the PR ❤️💜💙💛💚🖤

I'll take a look as soon as possible!

garaujodev commented 2 years ago

I'm assuming as maintainer for this gem. For my first releases, and to be in compliance with Semantic Version standards, I intend to be more conservative on releases.

I think that a good idea to reach it, is split this PR into 3 PRs:

@skryukov what do you think about? Could you split this PR into 3 mentioned PRs?

Please just let me know if you need help to do that.

skryukov commented 2 years ago

@garaujodev sounds fine.

What about support for ruby < 2.4? I believe the gem is still capable of supporting them (not sure about the strategies part though), we only need to downgrade some dev dependencies (including rubocop) to enable the test suite.

But is that worth the headache?

garaujodev commented 2 years ago

@skryukov I was thinking about it, because support for Ruby 2.4 was ended in 2020.

With that, I'm planning to release in this way (Current version: 2.2.0):

So, we can deprecate Ruby 2.4 in the same PR that introduce Ruby 3 support.

skryukov commented 2 years ago

Closing in favor of #128 #129 and #130