rtomayko/rack-cache

Support for multiple representations for a URL

dasch opened this issue · 5 comments

In some cases it makes sense to have multiple resources for the same URL, e.g. one for logged-in and one for anonymous users. I believe the spec supports this, as e.g. If-None-Match can contain a list of ETags.

I propose the following change:

  1. Rather than merely selecting the first matching cache entry for a request, get all matching entries.
  2. If one of them is still fresh, respond with that immediately.
  3. Otherwise – if they all need to be validated – collect the ETags and pass them all to the application in If-None-Match.
  4. If the application responds with 304, select the entry with the ETag found in the 304 response.

This would allow the application to control exactly what is returned to the client.

(Also, I'd be happy to implement this if you agree with the design.)

Boop +1

Sounds good ... @dasch want to make a PR ? ( I'm the maintainer now 😭 )

dasch commented

@grosser we've switched to caching with Nginx in the meantime :-x I probably won't have time to look at this in the short term, but it shouldn't be too difficult.