Caio Chassot
2005-Sep-28 12:52 UTC
serving non-html cached file with proper content-type via lighttpd
Hi all, 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?
Caio Chassot
2005-Sep-28 16:16 UTC
Re: serving non-html cached file with proper content-type via lighttpd
> 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. >Ok, I think I nailed it. Should anyone face the same problem, here''s what I did: In lighttpd.conf: url.rewrite = ( "^/$" => "index.html", "^(/rss[^.]*)$" => "$1.xml", # <== "^([^.]+)$" => "$1.html", ) In a file where you override ActionController::Base (must be done on base for sweeping to work): def page_cache_file(path) s = super s.sub!(/\.html$/, ".xml") if s =~ /^\/rss/ s end Maybe I''ll work on a patch that allows caches_page to specify a different extension for some actions.