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:
- Rather than merely selecting the first matching cache entry for a request, get all matching entries.
- If one of them is still fresh, respond with that immediately.
- Otherwise – if they all need to be validated – collect the ETags and pass them all to the application in
If-None-Match.
- 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.