My application has content that I''d like to cache, however that content varies from user to user. More specifically, the application is something like a forum, and the appearance of posts changes if the user who made the post is viewing it. (So theoretically there''s only two variations of the way the view is rendered, one for the author and one for any other user.) This combined with the fact that I am using relative dates has made it difficult for me to find a caching solution. Although I haven''t actually tried any of them, having read about them, I don''t think any of them fit my needs. What I am really trying to avoid is unneeded database queries. A post doesn''t change after its been made unless its edited, which is rare. However every time a user loads a page full of posts, queries are run to get the same data, over and over again. Not only that, but the way I am verifying whether or not a user did or didn''t make a post is using cookies - if the user has a cookie that matches him or her to the post he or she sees edit/delete icons in that post, so the way of verifying if the user owns a post is independent of the database and the controller and is something I reserve for the view/helper. So I really would like to just cut the controller/model out of the whole deal. Is there a way to cache the unchanging parts of a view and then update that view if necessary during rendering? Or, is there a way to cache just the results of the database query? -- 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 -~----------~----~----~----~------~----~------~--~---
> > Is there a way to cache the unchanging parts of a view and then update > that view if necessary during rendering? Or, is there a way to cache > just the results of the database query?Hi, I''m also studding caching mechanisms in RoR. If you need to cache a part of view you can use <% cache do %> <% end %>. Example(i cache a part of view for each language in my view): <% cache "langbar-#{get_current_lang}" do %> <%= render :partial => ''/langbar'' %> <% end %> It generates *.cache files in tmp/cache directory, and i get more reqs/sec. -- 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, but I don''t think that will be helpful in my case. Since I''ve already pre-loaded all the records before the view is even rendered, simply caching the views wouldn''t do me that much. -- 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 -~----------~----~----~----~------~----~------~--~---
You may will be interested in "Ambition" :http://errtheblog.com/post/ 10722 It could resolve the cache problem in view. On Sep 30, 6:11 am, "R. Elliott Mason" <rails-mailing-l...@andreas- s.net> wrote:> Thanks, but I don''t think that will be helpful in my case. Since I''ve > already pre-loaded all the records before the view is even rendered, > simply caching the views wouldn''t do me that much. > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
Also, you may want to take a look at beast - their forum solution is pretty efficient and its open sourced. On Sep 29, 4:07 am, "R. Elliott Mason" <rails-mailing-l...@andreas- s.net> wrote:> My application has content that I''d like to cache, however that content > varies from user to user. More specifically, the application is > something like a forum, and the appearance of posts changes if the user > who made the post is viewing it. (So theoretically there''s only two > variations of the way the view is rendered, one for the author and one > for any other user.) This combined with the fact that I am using > relative dates has made it difficult for me to find a caching solution. > Although I haven''t actually tried any of them, having read about them, I > don''t think any of them fit my needs. > > What I am really trying to avoid is unneeded database queries. A post > doesn''t change after its been made unless its edited, which is rare. > However every time a user loads a page full of posts, queries are run to > get the same data, over and over again. Not only that, but the way I am > verifying whether or not a user did or didn''t make a post is using > cookies - if the user has a cookie that matches him or her to the post > he or she sees edit/delete icons in that post, so the way of verifying > if the user owns a post is independent of the database and the > controller and is something I reserve for the view/helper. So I really > would like to just cut the controller/model out of the whole deal. > > Is there a way to cache the unchanging parts of a view and then update > that view if necessary during rendering? Or, is there a way to cache > just the results of the database query? > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
You could check if the cache exists and then run the queries only if it doesn''t? (using fragment caching) Also, there are options to cache queries using something like memcached - check out http://errtheblog.com/post/4872 On Sep 30, 6:11 am, "R. Elliott Mason" <rails-mailing-l...@andreas- s.net> wrote:> Thanks, but I don''t think that will be helpful in my case. Since I''ve > already pre-loaded all the records before the view is even rendered, > simply caching the views wouldn''t do me that much. > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
Well I think cache_fu or something along those lines would be the best option theoretically, but the presentation for it says you don''t need it unless your site is already huge. Plus I''m wondering, since it uses memory, if it will even be good for my shared hosting environment. I guess I''ll just put off caching. -- 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 -~----------~----~----~----~------~----~------~--~---