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?
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