Skip to content

Question about 304 NotModified #82

@gottfrois

Description

@gottfrois

I have the following scenario:

  1. GET some url, returns a cacheable (for couple seconds) result with proper headers
  2. GET same url within cached timeframe, does not hit the server, returns response directly from cache (great)
  3. GET same url when cache has expire, sends the request to server, server respond with a 304 no-cache.
  4. Middleware trace is valid, store, meaning it re-stored the original response back into cache store (great)
  5. GET same url within cached timeframe, should not hit the server but it actually re-validate the response.

Why is that? Since the last validate, the server respond with a 304 and the gem re-stored the response into the cache store. It should be able to pickup the cached response directly, at least while the cache entry is still fresh.

I think the issue is that when the gem ask if the entry is fresh here it's based on the max-age which is nil since it was a 304 with no-cache.

But correct me if I'm wrong, the no-cache statement is just for the 304 request, because you don't want to cache a 304 since it has empty body, but it does not mean you should not re-store the original response right?

Hope what I wrote is understandable..

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions