Hi, I''ve been reading the Rails Guide about caching and I have a few questions about it. I''ve read that it is not possible to cache a page with url parameters, for instance ''http://.../com/products/category_id=5''. Am I correct? Isn''t there any way to be able to do so? If caching is only able on ''conditions'' when do you use caching? Thanks Greg -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> > I''ve been reading the Rails Guide about caching and I have a few > questions about it. > I''ve read that it is not possible to cache a page with url parameters, > for instance ''http://.../com/products/category_id=5''. Am I correct? > Isn''t there any way to be able to do so? >You can do it, but it depends on how you format your URLs because it makes a static HTML file for Apache to serve (and Apache won''t serve files with GET parameters in the name). For example, if your URL is: http://www.example.com/products?category=5 This wouldn''t work because Apache automatically separates on ? and would look for a file called products.html (not your category 5 specific one). On the other hand if your URL was: http://www.example.com/products/category/5 Then it would work - the 5 would become 5.html in a folder called category in a folder called products. Caching works with parameters, just not normal GET parameters like ?foo=bar. Cheers, Andy -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Andy Jeffries wrote:> > You can do it, but it depends on how you format your URLs because it > makes a > static HTML file for Apache to serve (and Apache won''t serve files with > GET > parameters in the name). For example, if your URL is: > > http://www.example.com/products?category=5 > > This wouldn''t work because Apache automatically separates on ? and would > look for a file called products.html (not your category 5 specific one). > > On the other hand if your URL was: > > http://www.example.com/products/category/5 > > Then it would work - the 5 would become 5.html in a folder called > category > in a folder called products. > > Caching works with parameters, just not normal GET parameters like > ?foo=bar. > > Cheers, > > > AndyThank you Andy for you explanation. How do you do to make your urls look like this? Greg -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> > > http://www.example.com/products/category/5 > > > > Then it would work - the 5 would become 5.html in a folder called > > category > > in a folder called products. > > Thank you Andy for you explanation. > How do you do to make your urls look like this? >config/routes.rb map.category "/products/category/:id", :controller => "categories", :action => "show" How your URLs look is always a product of the Routing system. Cheers, Andy -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Andy Jeffries wrote:>> >> > http://www.example.com/products/category/5 >> > >> > Then it would work - the 5 would become 5.html in a folder called >> > category >> > in a folder called products. >> >> Thank you Andy for you explanation. >> How do you do to make your urls look like this? >> > > config/routes.rb > > map.category "/products/category/:id", :controller => "categories", > :action > => "show"Does the link_tag will still look like this: link_to "my link", products_path(:category_id => 3) ? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.