Howdy. I''m working on a RoR CMS and need cached pages to all be in public/cache rather than public [in order to set svn:ignore on all the files properly]. I can get page_cache_directory set correctly and the pages are cached in the right place but Mongrel isn''t serving them because it''s only looking for them in public. During development I know I can set -r public/cache but doing that means that the images and stylesheets don''t get picked up. I''m sure there''s a way to tell Mongrel to look in both places or at least to serve assets from public and cached pages from public/cache. Isn''t there? Thanks in advance. RSL -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20061031/e4c56b38/attachment.html
Russell Norris wrote:> Howdy. I''m working on a RoR CMS and need cached pages to all be in > public/cache rather than public [in order to set svn:ignore on all the > files properly]. I can get page_cache_directory set correctly and the > pages are cached in the right place but Mongrel isn''t serving them > because it''s only looking for them in public. During development I > know I can set -r public/cache but doing that means that the images > and stylesheets don''t get picked up. I''m sure there''s a way to tell > Mongrel to look in both places or at least to serve assets from public > and cached pages from public/cache. Isn''t there?You can always do this with apache. # Redirect any requests for cached content that exist to the cached url. RewriteCond %{DOCUMENT_ROOT}/cache/%{REQUEST_FILENAME} -f RewriteRule ^/(.*)$ /cache/$1 [PT] # Redirect all non-static requests to cluster RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f RewriteCond %{DOCUMENT_ROOT}/cache/%{REQUEST_FILENAME} !-f RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L] Or something like that (NOTE: I haven''t tested the above, but it "feels" right). - Ian C. Blenke <ian at blenke.com> http://ian.blenke.com/
On 10/31/06, Russell Norris <rsl at swimcommunity.org> wrote:> Howdy. I''m working on a RoR CMS and need cached pages to all be in > public/cache rather than public [in order to set svn:ignore on all the files > properly]. I can get page_cache_directory set correctly and the pages are > cached in the right place but Mongrel isn''t serving them because it''s only > looking for them in public. During development I know I can set -r > public/cache but doing that means that the images and stylesheets don''t get > picked up. I''m sure there''s a way to tell Mongrel to look in both places or > at least to serve assets from public and cached pages from public/cache. > Isn''t there? > > Thanks in advance. > > RSLI would think that you could just set up a custom DirHandler, but the RailsHandler is taking up the root uri. I''m not sure this would work, but use a config script like this: uri "/", Mongrel::DirHandler.new("path/to/public/cache", listing_allowed=true, index_html="index.html"), :in_front => true (the 2nd and 3rd params of DirHandler.new are optional). I''m not sure if the DirHandler will return 404''s or just pass on to the next handler in line, which would be the Rails Handler. If this doesn''t work, you''ll have to hack the RailsHandler probably. -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com
On 10/31/06, Russell Norris <rsl at swimcommunity.org> wrote:> Howdy. I''m working on a RoR CMS and need cached pages to all be in > public/cache rather than public [in order to set svn:ignore on all the files > properly]. I can get page_cache_directory set correctly and the pages are > cached in the right place but Mongrel isn''t serving them because it''s only > looking for them in public. During development I know I can set -r > public/cache but doing that means that the images and stylesheets don''t get > picked up. I''m sure there''s a way to tell Mongrel to look in both places or > at least to serve assets from public and cached pages from public/cache. > Isn''t there? > > Thanks in advance.I''m not sure if any of these will work, they''re just hints: 1. try prepend DirHandler mounted to public/cache :in_front of rails handler using -S switch uri "/", :handler => Mongrel::DirHandler.new("/public/cache", false) This will unfortunately not look for PATH_INFO + ''.html'' files. 2. try patching RailsHandler to look also in cache. For that a proxy handler would be useful - one that will hold more DirHandlers and will delegate to whichever wants to serve the particular file. In this case RailsHandler will take care of +.html files. You''d need to implement new, can_serve? and process which seems pretty easy.
On Tue, 31 Oct 2006 08:55:13 -0500 "Russell Norris" <rsl at swimcommunity.org> wrote:> Howdy. I''m working on a RoR CMS and need cached pages to all be in > public/cache rather than public [in order to set svn:ignore on all the files > properly]. I can get page_cache_directory set correctly and the pages are > cached in the right place but Mongrel isn''t serving them because it''s only > looking for them in public. During development I know I can set -r > public/cache but doing that means that the images and stylesheets don''t get > picked up. I''m sure there''s a way to tell Mongrel to look in both places or > at least to serve assets from public and cached pages from public/cache. > Isn''t there? >I believe there was a patch for this and that I applied it to the current pre-release. I''m super busy today, but I''ll be spending some time later in the afternoon on Mongrel. I''ll sit down and figure out how to dynamically determine this from the Rails configuration if I haven''t done that already. -- Zed A. Shaw, MUDCRAP-CE Master Black Belt Sifu http://www.zedshaw.com/ http://safari.oreilly.com/0321483502 -- The Mongrel Book http://mongrel.rubyforge.org/ http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.
I was thinking that DirHandler or RailsHandler would be the answer but I can''t seem to figure out what to do with them. The RDoc is, um... Let''s say "terse". And there''s nothing [that I saw] on the main site. Any chance you''ve seen a good breakdown/tutorial/whatever somewhere online? RSL On 10/31/06, Jan Svitok <jan.svitok at gmail.com> wrote:> > On 10/31/06, Russell Norris <rsl at swimcommunity.org> wrote: > > Howdy. I''m working on a RoR CMS and need cached pages to all be in > > public/cache rather than public [in order to set svn:ignore on all the > files > > properly]. I can get page_cache_directory set correctly and the pages > are > > cached in the right place but Mongrel isn''t serving them because it''s > only > > looking for them in public. During development I know I can set -r > > public/cache but doing that means that the images and stylesheets don''t > get > > picked up. I''m sure there''s a way to tell Mongrel to look in both places > or > > at least to serve assets from public and cached pages from public/cache. > > Isn''t there? > > > > Thanks in advance. > > I''m not sure if any of these will work, they''re just hints: > > 1. try prepend DirHandler mounted to public/cache :in_front of rails > handler using -S switch > uri "/", :handler => Mongrel::DirHandler.new("/public/cache", > false) > This will unfortunately not look for PATH_INFO + ''.html'' files. > > 2. try patching RailsHandler to look also in cache. For that a proxy > handler > would be useful - one that will hold more DirHandlers and will > delegate to whichever > wants to serve the particular file. In this case RailsHandler will > take care of +.html files. > You''d need to implement new, can_serve? and process which seems pretty > easy. > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20061031/8325bac9/attachment-0001.html
I feel bad now. I didn''t mean to add more to your plate, Zed. RSL On 10/31/06, Zed A. Shaw <zedshaw at zedshaw.com> wrote:> > On Tue, 31 Oct 2006 08:55:13 -0500 > "Russell Norris" <rsl at swimcommunity.org> wrote: > > > Howdy. I''m working on a RoR CMS and need cached pages to all be in > > public/cache rather than public [in order to set svn:ignore on all the > files > > properly]. I can get page_cache_directory set correctly and the pages > are > > cached in the right place but Mongrel isn''t serving them because it''s > only > > looking for them in public. During development I know I can set -r > > public/cache but doing that means that the images and stylesheets don''t > get > > picked up. I''m sure there''s a way to tell Mongrel to look in both places > or > > at least to serve assets from public and cached pages from public/cache. > > Isn''t there? > > > > I believe there was a patch for this and that I applied it to the current > pre-release. I''m super busy today, but I''ll be spending some time later in > the afternoon on Mongrel. > > I''ll sit down and figure out how to dynamically determine this from the > Rails configuration if I haven''t done that already. > > -- > Zed A. Shaw, MUDCRAP-CE Master Black Belt Sifu > http://www.zedshaw.com/ > http://safari.oreilly.com/0321483502 -- The Mongrel Book > http://mongrel.rubyforge.org/ > http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help. > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20061031/810d2271/attachment.html
Rick, that did the trick. Thank you so much! RSL On 10/31/06, Rick Olson <technoweenie at gmail.com> wrote:> > On 10/31/06, Russell Norris <rsl at swimcommunity.org> wrote: > > Howdy. I''m working on a RoR CMS and need cached pages to all be in > > public/cache rather than public [in order to set svn:ignore on all the > files > > properly]. I can get page_cache_directory set correctly and the pages > are > > cached in the right place but Mongrel isn''t serving them because it''s > only > > looking for them in public. During development I know I can set -r > > public/cache but doing that means that the images and stylesheets don''t > get > > picked up. I''m sure there''s a way to tell Mongrel to look in both places > or > > at least to serve assets from public and cached pages from public/cache. > > Isn''t there? > > > > Thanks in advance. > > > > RSL > > I would think that you could just set up a custom DirHandler, but the > RailsHandler is taking up the root uri. I''m not sure this would work, > but use a config script like this: > > uri "/", Mongrel::DirHandler.new("path/to/public/cache", > listing_allowed=true, index_html="index.html"), :in_front => true > > (the 2nd and 3rd params of DirHandler.new are optional). > > I''m not sure if the DirHandler will return 404''s or just pass on to > the next handler in line, which would be the Rails Handler. If this > doesn''t work, you''ll have to hack the RailsHandler probably. > > -- > Rick Olson > http://weblog.techno-weenie.net > http://mephistoblog.com > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20061031/d1bd2a36/attachment.html
I spoke too soon. Things are still caching in the wrong place. :/ I think I''ve looked at these directories so long they''ve stopped making sense even to me. Anyhow, I''m looking at the RailsHandler now. RSL On 10/31/06, Russell Norris <rsl at swimcommunity.org> wrote:> > Rick, that did the trick. Thank you so much! > > RSL > > On 10/31/06, Rick Olson <technoweenie at gmail.com> wrote: > > > > On 10/31/06, Russell Norris <rsl at swimcommunity.org > wrote: > > > Howdy. I''m working on a RoR CMS and need cached pages to all be in > > > public/cache rather than public [in order to set svn:ignore on all the > > files > > > properly]. I can get page_cache_directory set correctly and the pages > > are > > > cached in the right place but Mongrel isn''t serving them because it''s > > only > > > looking for them in public. During development I know I can set -r > > > public/cache but doing that means that the images and stylesheets > > don''t get > > > picked up. I''m sure there''s a way to tell Mongrel to look in both > > places or > > > at least to serve assets from public and cached pages from > > public/cache. > > > Isn''t there? > > > > > > Thanks in advance. > > > > > > RSL > > > > I would think that you could just set up a custom DirHandler, but the > > RailsHandler is taking up the root uri. I''m not sure this would work, > > but use a config script like this: > > > > uri "/", Mongrel:: DirHandler.new("path/to/public/cache", > > listing_allowed=true, index_html="index.html"), :in_front => true > > > > (the 2nd and 3rd params of DirHandler.new are optional). > > > > I''m not sure if the DirHandler will return 404''s or just pass on to > > the next handler in line, which would be the Rails Handler. If this > > doesn''t work, you''ll have to hack the RailsHandler probably. > > > > -- > > Rick Olson > > http://weblog.techno-weenie.net > > http://mephistoblog.com > > _______________________________________________ > > Mongrel-users mailing list > > Mongrel-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/mongrel-users > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20061031/ff5ee22e/attachment.html
On 10/31/06, Russell Norris <rsl at swimcommunity.org> wrote:> Rick, that did the trick. Thank you so much! > > RSLWhich? The config script? That''s cool... I''d suggest implementing this in various web servers too. Apache/nginx/lighty handle this stuff much better and can leave mongrel for doing rails stuff. Still, it''s good to have a fallback like this. That''s why I love mongrel :) -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com
Unfortunately, it wasn''t the config but hacking the RailsHandler that ended up working. I hard-coded my copy but I can imagine how easily you could generate a path_info/page_cached from the value in ActionController:: Base.page_cache_directory. I''m sure that''s what Zed and co. probably have in the new version. Anyhow, I wanted to thank all for you kittens for helping. Thanks. RSL On 10/31/06, Rick Olson <technoweenie at gmail.com> wrote:> > On 10/31/06, Russell Norris <rsl at swimcommunity.org> wrote: > > Rick, that did the trick. Thank you so much! > > > > RSL > > Which? The config script? That''s cool... > > I''d suggest implementing this in various web servers too. > Apache/nginx/lighty handle this stuff much better and can leave > mongrel for doing rails stuff. Still, it''s good to have a fallback > like this. That''s why I love mongrel :) > > > -- > Rick Olson > http://weblog.techno-weenie.net > http://mephistoblog.com > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20061031/ab220cf3/attachment.html
On 10/31/06, Russell Norris <rsl at swimcommunity.org> wrote:> I was thinking that DirHandler or RailsHandler would be the answer but I > can''t seem to figure out what to do with them. The RDoc is, um... Let''s say > "terse". And there''s nothing [that I saw] on the main site. Any chance > you''ve seen a good breakdown/tutorial/whatever somewhere online?The mongrel source is very clean and easy to follow. -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com
On 10/31/06, Russell Norris <rsl at swimcommunity.org> wrote:> I feel bad now. I didn''t mean to add more to your plate, Zed. > > RSLI think this is definitely mongrel plugin territory. Not too many apps do this kind of thing. Mephisto does, but I rely on the web server to rewrite properly. -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com