On Wed, 28 Sep 2005, Caio Chassot <k@v2studio.com> wrote:> I have a site that makes heavy use of caching and is served through > lighttpd. One of the pages that is cached is the rss feed, which should > be served as text/xml. > > Seeing as rails caches pages with a .html extension, it''s being served > with a html content-type. I know how to work around this via apache, > but not via lighttpd. > > Has anyone had to deal with this before? Any pointers?Here''s an excerpt from my lighttpd.conf. Basically it internally rewrites /feeds/* to /feeds/*.xml. If there''s no cache, Rails serves it with its own content-type header, then saves it as whatever.xml. Next time, lighttpd recognizes the .xml and serves it with the right content-type. url.rewrite = ( "^/feeds/([^.]+)$" => "/feeds/$1.xml" ) Maybe this is already done in edge Rails, but it would be really nice if Rails came with an example lighttpd.conf (or a generator). Lighty is becoming the defacto standard for serving Rails apps, but page caching doesn''t work with it out of the box, and its documentation is sparse at best. I finally puzzled it out, but we could easily lower that hurdle for new users. Scott Raymond scottraymond.net blinksale.com
Caio Chassot
2005-Sep-28 17:36 UTC
Re: serving non-html cached file with proper content-type
> > Here''s an excerpt from my lighttpd.conf. Basically it internally > rewrites /feeds/* to /feeds/*.xml. If there''s no cache, Rails serves > it with its own content-type header, then saves it as whatever.xml. > Next time, lighttpd recognizes the .xml and serves it with the right > content-type. >But how do you get rails to use .xml extension? I had to resort to overriding page_cache_file.
Jarkko Laine
2005-Sep-28 18:51 UTC
Re: serving non-html cached file with proper content-type
On 28.9.2005, at 20.36, Caio Chassot wrote:>> >> Here''s an excerpt from my lighttpd.conf. Basically it internally >> rewrites /feeds/* to /feeds/*.xml. If there''s no cache, Rails serves >> it with its own content-type header, then saves it as whatever.xml. >> Next time, lighttpd recognizes the .xml and serves it with the right >> content-type. >> >> > > But how do you get rails to use .xml extension?Routing, baby, routing ;-) From typo: # make rss feed urls pretty and let them end in .xml # this improves caches_page because now apache and webrick will send out the # cached feeds with the correct xml mime type. map.xml ''xml/articlerss/:id/feed.xml'', :controller => ''xml'', :action => ''articlerss'' //jarkko> I had to resort to overriding page_cache_file. > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >-- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Caio Chassot
2005-Sep-29 05:10 UTC
Re: serving non-html cached file with proper content-type
> Routing, baby, routing ;-) > > From typo: > # make rss feed urls pretty and let them end in .xml > # this improves caches_page because now apache and webrick will send > out the > # cached feeds with the correct xml mime type. > map.xml ''xml/articlerss/:id/feed.xml'', :controller => ''xml'', :action > => ''articlerss'' >This seems like the cleanest solution given the way rails currently works. But it''s questionable wether feeds having a xml extension is a /pretty/ url. (cf. siracusa''s piece on metadata)