Loading...
Loading...

Reputation: 913

Rails default behavior: Why is Rails not generating different Etags by default or returning 304 Not Modified?

I am inspecting a Rails response. No http headers have been purposefully set to be returned from the server.

The response includes Cache-Control: max-age=0, private, must-revalidate and Etag. The response is a 200 no matter how many times I make the same request or within how short a period of time.

My questions are:

  1. How is the Etag being generated if I didn't set a stale? or fresh_when in the response? The Etag is always the same for this endpoint.
  2. Regardless of how the Etag is being generated, if it is always the same, why isn't the server noticing that the Etag is the always the same and responding with a 304 rather than a 200?

Thank you

Upvotes: 2

Views: 407

Answers (1)

Andrea Salicetti
Andrea Salicetti

Reputation: 2483

  • One of the reason might be the presence of mini_profiler, as by default that gem overrides some cache related headers (see here why and how to fix it).
  • Another one is that you have config.action_controller.perform_caching = false.

Upvotes: 0

Related Questions