Hi, I am caching the index page for a resource using caches_page :index. Now it looks like when I POST a resource to the same (index-)URL which should be routed to the ''create'' method, the rails app doesn''t even process the request (I get no log output) but the cached page is served instead. Is this a bug, or does one need to specify the HTTP method in the call to caches_page somehow (can''t find anything in the documentation) to make sure that only GET requests are cached? Ingo -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hmm, guess I don''t understand this yet. Let''s use an example: Writing ''map.resources :users'' in routes.rb gives me the following routes: GET /users/ {:action=>"index", :controller=>"users"} POST /users/ {:action=>"create", :controller=>"users"} when I use caches_page :index, how can I prevent a POST to /users from bringing up the cached index page? Or are you saying that it is not possible to use unmodified REST routes with caching this way? Ingo Philip Hallstrom wrote:>> I am caching the index page for a resource using caches_page :index. Now >> it looks like when I POST a resource to the same (index-)URL which >> should be routed to the ''create'' method, the rails app doesn''t even >> process the request (I get no log output) but the cached page is served >> instead. Is this a bug, or does one need to specify the HTTP method in >> the call to caches_page somehow (can''t find anything in the >> documentation) to make sure that only GET requests are cached? > > This is normal. If you cache a page/URL and make any sort of request to > that same URL your webserver is going to "process" that page, not skip > it > and hand it to Rails. > > Why not change your POST''s action to point to the ''create'' route/URL > directly?-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> I am caching the index page for a resource using caches_page :index. Now > it looks like when I POST a resource to the same (index-)URL which > should be routed to the ''create'' method, the rails app doesn''t even > process the request (I get no log output) but the cached page is served > instead. Is this a bug, or does one need to specify the HTTP method in > the call to caches_page somehow (can''t find anything in the > documentation) to make sure that only GET requests are cached?This is normal. If you cache a page/URL and make any sort of request to that same URL your webserver is going to "process" that page, not skip it and hand it to Rails. Why not change your POST''s action to point to the ''create'' route/URL directly? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Hmm, guess I don''t understand this yet. Let''s use an example: Writing > ''map.resources :users'' in routes.rb gives me the following routes: > > GET /users/ {:action=>"index", :controller=>"users"} > POST /users/ {:action=>"create", :controller=>"users"} > > when I use caches_page :index, how can I prevent a POST to /users from > bringing up the cached index page? Or are you saying that it is not > possible to use unmodified REST routes with caching this way?I don''t think REST is even involved here. Your first route results in a cached file to public/users/index.html. Any additional requests (GET/POST/etc) to /users/ and your web server (apache/lighttpd) is going to return the content in public/users/index.html and never pass the request on to Rails. -philip> > Ingo > > > > Philip Hallstrom wrote: >>> I am caching the index page for a resource using caches_page :index. Now >>> it looks like when I POST a resource to the same (index-)URL which >>> should be routed to the ''create'' method, the rails app doesn''t even >>> process the request (I get no log output) but the cached page is served >>> instead. Is this a bug, or does one need to specify the HTTP method in >>> the call to caches_page somehow (can''t find anything in the >>> documentation) to make sure that only GET requests are cached? >> >> This is normal. If you cache a page/URL and make any sort of request to >> that same URL your webserver is going to "process" that page, not skip >> it >> and hand it to Rails. >> >> Why not change your POST''s action to point to the ''create'' route/URL >> directly? > > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks Philip! I will try using action caching instead, and see whether that makes a difference (although I would hate to lose part of the performance gain this way) Ingo Philip Hallstrom wrote:>> Hmm, guess I don''t understand this yet. Let''s use an example: Writing >> ''map.resources :users'' in routes.rb gives me the following routes: >> >> GET /users/ {:action=>"index", :controller=>"users"} >> POST /users/ {:action=>"create", :controller=>"users"} >> >> when I use caches_page :index, how can I prevent a POST to /users from >> bringing up the cached index page? Or are you saying that it is not >> possible to use unmodified REST routes with caching this way? > > I don''t think REST is even involved here. Your first route results in a > cached file to public/users/index.html. Any additional requests > (GET/POST/etc) to /users/ and your web server (apache/lighttpd) is going > to return the content in public/users/index.html and never pass the > request on to Rails. > > -philip-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---