Greetings,
How do I turn off ETag(s) in Ruby on Rails v2.3.5
When I do a direct request to to the RoR/Mongrel an ETag header is present.
TIA,
-daniel
much easier:
config.middleware.delete Rack::ETag
Putting response.etag = nil
in a before_filter does not work. The etag is generated just before the response is send (it's caluculated from the body so after all rendering has been done).
The proper workaround to disable etag use and generation (and so save the time spend in md5) it this monkey patch:
module ActionController
class Request
# never match any incomming etag
def etag_matches?(etag)
false
end
end
class Response
# fake rails that our response already has an etag set and so none is generated automatically
def etag?
true
end
end
end
There's an etag
setter method on the ActionController::Response
object, which deletes the ETag HTTP header if it's blank, so you should just be able to clear it in your controller (probably in a before filter):
response.etag = nil
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With