I have a feeds controller which generates RSS and Atom pages. I put ''caches_page :show'' in it. The problem is that the pages are saved with an html extension. As a result, browsers display the cached feeds as HTML rather than XML, and feed validators complain. There''s an option to set ''Base.page_cache_extension'' globally, but I don''t want to do that for everything. I also tried setting that option just in the show method, but that doesn''t work. How can I get the cached pages for just Feeds#show get saved with xml/rss/atom extensions? Thanks csn -- Posted via http://www.ruby-forum.com/.
On 2/4/06, csn <cool_screen_name90001@yahoo.com> wrote:> I have a feeds controller which generates RSS and Atom pages. I put > ''caches_page :show'' in it. The problem is that the pages are saved with > an html extension. As a result, browsers display the cached feeds as > HTML rather than XML, and feed validators complain. > > There''s an option to set ''Base.page_cache_extension'' globally, but I > don''t want to do that for everything. I also tried setting that option > just in the show method, but that doesn''t work. How can I get the cached > pages for just Feeds#show get saved with xml/rss/atom extensions? > > Thanks > csnIt''s kind of hackish I think, but I set it in the route, and then send it to the correct action in the controller: map.xml ''xml/:file'', :controller => ''syndicate'', :action => ''xml'', :requirements => { :file => /^\w+\.xml$/ } http://collaboa.techno-weenie.net/repository/file/rails_help/app/controllers/syndicate_controller.rb -- Rick Olson http://techno-weenie.net
csn wrote:>I have a feeds controller which generates RSS and Atom pages. I put >''caches_page :show'' in it. The problem is that the pages are saved with >an html extension. As a result, browsers display the cached feeds as >HTML rather than XML, and feed validators complain. > >There''s an option to set ''Base.page_cache_extension'' globally, but I >don''t want to do that for everything. I also tried setting that option >just in the show method, but that doesn''t work. How can I get the cached >pages for just Feeds#show get saved with xml/rss/atom extensions? > >Thanks >csn > > >I ended up setting the content-type conditionally in lighttpd based on the path. I''m sure you can do the same in Apache.
--- Rick Olson <technoweenie@gmail.com> wrote:> On 2/4/06, csn <cool_screen_name90001@yahoo.com> > wrote: > > I have a feeds controller which generates RSS and > Atom pages. I put > > ''caches_page :show'' in it. The problem is that the > pages are saved with > > an html extension. As a result, browsers display > the cached feeds as > > HTML rather than XML, and feed validators > complain. > > > > There''s an option to set > ''Base.page_cache_extension'' globally, but I > > don''t want to do that for everything. I also tried > setting that option > > just in the show method, but that doesn''t work. > How can I get the cached > > pages for just Feeds#show get saved with > xml/rss/atom extensions? > > > > Thanks > > csn > > It''s kind of hackish I think, but I set it in the > route, and then send > it to the correct action in the controller: > > map.xml ''xml/:file'', :controller => ''syndicate'', > :action => ''xml'', > :requirements => { :file => /^\w+\.xml$/ } > >http://collaboa.techno-weenie.net/repository/file/rails_help/app/controllers/syndicate_controller.rb Rick Thanks. What does your caches_page_with_references function do? I briefly looked around your repository, but didn''t see its definition. csn> > -- > Rick Olson > http://techno-weenie.net > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
--- csn <cool_screen_name90001@yahoo.com> wrote:> I have a feeds controller which generates RSS and > Atom pages. I put > ''caches_page :show'' in it. The problem is that the > pages are saved with > an html extension. As a result, browsers display the > cached feeds as > HTML rather than XML, and feed validators complain. > > There''s an option to set ''Base.page_cache_extension'' > globally, but I > don''t want to do that for everything. I also tried > setting that option > just in the show method, but that doesn''t work. How > can I get the cached > pages for just Feeds#show get saved with > xml/rss/atom extensions?I''ve made some progress. Changing @@page_cache_extension to ''.xml'' in the controller causes the cache files to get saved with an xml entension. However, I can''t get them to get used. I added this to my .htaccess: RewriteRule ^(feeds/[^.]+)$ $1.xml [QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ dispatch.cgi [QSA,L] above the standard: RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ dispatch.cgi [QSA,L] The production shows that xml cache files aren''t used, but html ones are. I even tried just this in the .htaccess: RewriteRule ^([^.]+)$ $1.xml [QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ dispatch.cgi [QSA,L] But those cache files STILL aren''t getting used. The above ruleset should cause EVERY request sans file extension to get rewritten to $1.xml, but it apparently isn''t working. I have no idea why. Only .html works. I''m using webrick (in production mode). Any ideas? Thanks, csn __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com