Ramon Tayag
2011-Nov-05 17:14 UTC
How to get Rails 3.1''s Cache store (FileStore) to work with Rack::Sendfile
Hey - I need your input regarding a problem I''ve come across. I''ll first explain what the problem is, and what I think the solution is. If I misunderstood how things work, please let me know. # The problem I''m using Dragonfly (on-the-fly file processing) to serve images. Dragonfly uses Rack::Cache to cache the processed images so subsequent requests are served by Rack::Cache. The problem lies in Rack::Cache getting too busy serving images. I thought the fix would be to let Rack::Cache use Apache''s X-Sendfile to serve images. You can read my journey in a StackOverflow question I posted <http://stackoverflow.com/q/7980106/61018>. # The solution The solution would be to enable whatever''s needed to get Rack::Cache to serve files using X-Sendfile through Rack::Sendfile. After poking around Rack::Cache, I found out that none of the Rack::Cache Entitystores are used -- what''s being used is Rails'' own storage solution<https://github.com/rails/rails/blob/3-1-stable/activesupport/lib/active_support/cache/file_store.rb> . Is there a reason that FileStore doesn''t support Rack::Sendfile at the moment (why it uses Marshal)? What would be the easiest way to get to what I need? Can I just tell Rails to use Rack::Cache''s Disk entitystore? If not, what do you guys think of letting the *body* of the *response* of * FileStore* (yes, a bit of a mouthful) to respond to `to_path`? Thanks! Ramon Tayag -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2011-Nov-05 18:28 UTC
Re: How to get Rails 3.1''s Cache store (FileStore) to work with Rack::Sendfile
On Nov 5, 5:14 pm, Ramon Tayag <ra...-xzN5gvnvA7heoWH0uzbU5w@public.gmane.org> wrote:> Hey - I need your input regarding a problem I''ve come across. I''ll first > explain what the problem is, and what I think the solution is. If I > misunderstood how things work, please let me know. > > # The problem > > I''m using Dragonfly (on-the-fly file processing) to serve images. Dragonfly > uses Rack::Cache to cache the processed images so subsequent requests are > served by Rack::Cache. The problem lies in Rack::Cache getting too busy > serving images. I thought the fix would be to let Rack::Cache use Apache''s > X-Sendfile to serve images. You can read my journey in a StackOverflow > question I posted <http://stackoverflow.com/q/7980106/61018>. >Not really answering your question, but I''ve handled this situation by putting varnish in front of apache. Fred> # The solution > > The solution would be to enable whatever''s needed to get Rack::Cache to > serve files using X-Sendfile through Rack::Sendfile. After poking around > Rack::Cache, I found out that none of the Rack::Cache Entitystores are used > -- what''s being used is Rails'' own storage > solution<https://github.com/rails/rails/blob/3-1-stable/activesupport/lib/acti...> > . > > Is there a reason that FileStore doesn''t support Rack::Sendfile at the > moment (why it uses Marshal)? What would be the easiest way to get to what > I need? Can I just tell Rails to use Rack::Cache''s Disk entitystore? If > not, what do you guys think of letting the *body* of the *response* of * > FileStore* (yes, a bit of a mouthful) to respond to `to_path`? > > Thanks! > Ramon Tayag-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ramon
2011-Nov-06 02:49 UTC
Re: How to get Rails 3.1''s Cache store (FileStore) to work with Rack::Sendfile
Isn''t Varnish for much busier sites though? I tried going this route but I thought that this might be overkill. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/_MYfFRswfaIJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2011-Nov-06 12:22 UTC
Re: How to get Rails 3.1''s Cache store (FileStore) to work with Rack::Sendfile
On Nov 6, 2:49 am, Ramon <ramon.ta...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Isn''t Varnish for much busier sites though? I tried going this route but I > thought that this might be overkill.Well it does add one more thing to what your server runs but I found it relatively easy to use. It does also have the benefit of cutting ruby out of the picture completely when serving assets. 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.