Forum: Ruby on Rails How to get Rails 3.1's Cache store (FileStore) to work with Rack::Sendfile

E4eed90048c2c1281620b96937abee80?d=identicon&s=25 Ramon Tayag (Guest)
on 2011-11-05 18:16
(Received via mailing list)
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/act...
.

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
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2011-11-05 19:29
(Received via mailing list)
On Nov 5, 5:14pm, Ramon Tayag <ra...@tayag.net> wrote:
> 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
Fbd9cb107fe7c941333d6a3488691989?d=identicon&s=25 Ramon Tayag (ramontayag)
on 2011-11-06 03:50
(Received via mailing list)
Isn't Varnish for much busier sites though? I tried going this route but
I
thought that this might be overkill.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2011-11-06 13:24
(Received via mailing list)
On Nov 6, 2:49am, Ramon <ramon.ta...@gmail.com> 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
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.