Manfred / Reynard

Minimal OpenAPI client for Ruby.
MIT License
12 stars 2 forks source link

Implement a storage interface for cross-request state #13

Open Manfred opened 2 years ago

Manfred commented 2 years ago

The HTTP protocol has a number of features that require you to store bits of information between HTTP requests. We would like to support this somehow with a generic protocol that allows for different backends.

Manfred commented 11 months ago

Let's start with implementing conditional requests with a cache backend and work from there.

Manfred commented 11 months ago

From an HTTP consumer perspective there are two scenarios where you use conditional requests:

  1. When you want an automatic and transparent cache you send If-Modified-Since and If-None-Match request headers
  2. When you have a specific implementation that acts like caching, for example a client that performs document replication from cloud storage

When you want a transparent cache (1) you may want to terminate TLS somewhere else and use a caching proxy internally so you can shared the cache easily across various instances of the consumer.

So the question is: is there sufficient value in keeping an application level cache (eg. Redis or Memcached) instead of using a caching proxy that was purposely built for this?

The answer is probably: yes, but then it has to be a drop-in setup with a very opinionated implementation.

In the second case (2) you will need to store your last-modified-at and etag values with the actual documents that were created based on HTTP responses and there is no reason for Reynard to get in the way.