Rack:Static with other middlewares

5 views
Skip to first unread message

Matthew M. Boedicker

unread,
Apr 20, 2010, 11:22:09 PM4/20/10
to rack-...@googlegroups.com
When Rack::Static is used under Passenger it seems like the request is served by Apache and none of the other middlewares in the chain are run. Is this correct?

Is there any way to serve static files but also run them through other middlewares such as deflater and cache? When running under rackup it uses all the middleware and I would like the application to always behave the same.

Konstantin Haase

unread,
Apr 21, 2010, 1:53:43 AM4/21/10
to rack-...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On Apr 21, 2010, at 05:22 , Matthew M. Boedicker wrote:

> When Rack::Static is used under Passenger it seems like the request is served by Apache and none of the other middlewares in the chain are run. Is this correct?

Usually you want that behavior, as Apache is much better at throwing static files at the browser. Handing the data through your application is a rather large overhead.

> Is there any way to serve static files but also run them through other middlewares such as deflater and cache? When running under rackup it uses all the middleware and I would like the application to always behave the same.
>

Use File.read or something instead of Rack::Static. If it's only about deflation/cashing, then you might want to consider setting that up on apache or even load balancer level.

Konstantin

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)

iQEcBAEBAgAGBQJLzpLqAAoJEM+qkfuqK1IXJuQIALUP92l8SimI94g3bkWfcDLM
y7EwHYiOWpPln83qZl/7ug931yxC3Q0MI7reRiJnqj6F96QDvMWS2/9kDb+BF/op
Rlvl1imEF3OW5ug+ZZHJduqm2QXldPZBNd/SJHMmUMXZth3xakl1mNbxL/gkm0Ou
lyYBxJBl/VhXcImpju997//5jfPcqeXukyi0Ea3RE3q1iQepkM9lXqBKvJ3gdI4B
o8Xn2+A4Sbus0TzI0LB19r0Vz+tvdtl9I3wbEvpq310ghcUEDsx59a5wvjfBKWOc
eEq9ABQNjK2Is/ekTsTrBwnHiCVGzEj2Yrmv+Zsq5yZDykrRg3DHk4kGEXKI8xM=
=j9Lj
-----END PGP SIGNATURE-----


--
Subscription settings: http://groups.google.com/group/rack-devel/subscribe?hl=en

Matthew M. Boedicker

unread,
Apr 21, 2010, 6:56:49 PM4/21/10
to rack-...@googlegroups.com
After more testing it looks like it was calling other middlewares for Rack::Static served files, but not if they were in the public directory. Passenger skips rack entirely for anything in public (where rackup sends those requests through rack). Not sure if this is the default Passenger behavior or something that my host has configured.

Mateo Murphy

unread,
Apr 26, 2010, 4:28:45 PM4/26/10
to rack-...@googlegroups.com

On 21-Apr-10, at 6:56 PM, Matthew M. Boedicker wrote:

> After more testing it looks like it was calling other middlewares
> for Rack::Static served files, but not if they were in the public
> directory. Passenger skips rack entirely for anything in public
> (where rackup sends those requests through rack). Not sure if this
> is the default Passenger behavior or something that my host has
> configured.

This is standard Passenger behavior, as in most cases this is exactly
what you want
Reply all
Reply to author
Forward
0 new messages