How does Rails generate ETags by default? I've got config.action_controller.
perform_caching set to true in production so that I can use page-level
caching in a few specific places, but it seems that Rails is automatically
setting ETags on *all* responses even though I'm not using fresh_when or
the stale? helpers in any of my actions. How is Rails deciding to do this
and how do I disable it without killing page caching?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/m-0ndQSrx20J.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Frederick Cheung at Oct 3, 2012 at 10:13 am

    On Tuesday, October 2, 2012 9:50:39 PM UTC+1, jcoleman wrote:
    How does Rails generate ETags by default? I've got config.
    action_controller.perform_caching set to true in production so that I can
    use page-level caching in a few specific places, but it seems that Rails is
    automatically setting ETags on *all* responses even though I'm not using
    fresh_when or the stale? helpers in any of my actions. How is Rails
    deciding to do this and how do I disable it without killing page caching?
    The Rack::Etag middleware does this, using an MD5 of the response body as
    the actual etag. I would have thought that removing Rack::ETag from the
    middleware stack would hobble this.

    Fred

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/wkhYqV2j6DAJ.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jcoleman at Oct 3, 2012 at 1:11 pm
    Is there a way to disable certain middleware based on the route? Part of my
    application is an API that shouldn't really ever be sending 304's while I'm
    fine with the web application doing that. It seems like removing
    Rack::ConditionalGet should eliminate the setting of the 304 when the ETags
    match, but I don't see a way in the documentation to remove middleware
    non-globally.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/IqF4NHZtjkwJ.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Frederick Cheung at Oct 3, 2012 at 3:14 pm

    On Wednesday, October 3, 2012 2:11:33 PM UTC+1, jcoleman wrote:
    Is there a way to disable certain middleware based on the route? Part of
    my application is an API that shouldn't really ever be sending 304's while
    I'm fine with the web application doing that. It seems like removing
    Rack::ConditionalGet should eliminate the setting of the 304 when the ETags
    match, but I don't see a way in the documentation to remove middleware
    non-globally.

    I don't think so, at least not without splitting out your api into an
    engine which would then (IIRC - engines aren't something I've really used)
    have its own middleware stack.

    It should however be relatively easy to write your own middleware which,
    depending on the path, either calls through to the next item in the stack
    or invokes the Rack::Etag stuff and then replace the Rack::Etag middleware
    with that

    Fred

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/4GrTZSJ9QQ8J.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jcoleman at Oct 3, 2012 at 5:08 pm
    I ended up inserting my own middleware before Rack::Cache (which was
    actually causing the issue--I'd even tried removing Rack::ConditonalGet and
    the issue was still happening) that removes the If-None-Matches and
    If-Modified-Since headers on the matching requests.

    Thanks for the help!

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/519tOXU9RrgJ.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedOct 3, '12 at 9:31a
activeOct 3, '12 at 5:08p
posts5
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Jcoleman: 3 posts Frederick Cheung: 2 posts

People

Translate

site design / logo © 2022 Grokbase