Jian Lin
2010-Jun-04 10:31 UTC
Can Rails cache a Controller "as long as code not changed"?
At work, we have a situation where when script/server is run, then all the controller code is cached. This is to speed up the development server. But that will mean that whenever we change the controller code, we need to restart the server. So we can turn off the caching of controller code all together. But can''t there be mechanism that is similar to the inclusion of javascript foo.js?1273424325 which is to use the cached version as long as there is no code change, but recompile it when there is code change? Maybe because we use HAML and SASS a lot, loading some page (such as the homepage of the site) can take 40 seconds on the dev environment and it is quite long. -- 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.
Marnen Laibow-Koser
2010-Jun-04 14:23 UTC
Re: Can Rails cache a Controller "as long as code not change
Jian Lin wrote:> At work, we have a situation where when > > script/server > > is run, then all the controller code is cached. This is to speed up the > development server. But that will mean that whenever we change the > controller code, we need to restart the server.Yes, that''s normal behavior in development mode.> > So we can turn off the caching of controller code all together. But > can''t there be mechanism that is similar to the inclusion of javascript > > foo.js?1273424325 > > which is to use the cached version as long as there is no code change, > but recompile it when there is code change?Because it''s a different kind of caching. JavaScript caching simply involves using the browser cache for included files, whereas controller caching involves Ruby objects in memory on the server.> > Maybe because we use HAML and SASS a lot, loading some page (such as the > homepage of the site) can take 40 seconds on the dev environment and it > is quite long.Haml and Sass shouldn''t be having that effect. Look elsewhere for your problems. The fact that you''re asking this makes me think that you want *page* caching, not controller caching. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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.
Colin Law
2010-Jun-04 15:25 UTC
Re: Re: Can Rails cache a Controller "as long as code not change
On 4 June 2010 15:23, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Jian Lin wrote: >> At work, we have a situation where when >> >> script/server >> >> is run, then all the controller code is cached. This is to speed up the >> development server. But that will mean that whenever we change the >> controller code, we need to restart the server. > > Yes, that''s normal behavior in development mode.I thought that was the normal behaviour in production mode, not development. Colin> >> >> So we can turn off the caching of controller code all together. But >> can''t there be mechanism that is similar to the inclusion of javascript >> >> foo.js?1273424325 >> >> which is to use the cached version as long as there is no code change, >> but recompile it when there is code change? > > Because it''s a different kind of caching. JavaScript caching simply > involves using the browser cache for included files, whereas controller > caching involves Ruby objects in memory on the server. > >> >> Maybe because we use HAML and SASS a lot, loading some page (such as the >> homepage of the site) can take 40 seconds on the dev environment and it >> is quite long. > > Haml and Sass shouldn''t be having that effect. Look elsewhere for your > problems. > > The fact that you''re asking this makes me think that you want *page* > caching, not controller caching. > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > > -- > 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@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Jun-04 15:47 UTC
Re: Re: Can Rails cache a Controller "as long as code not c
Colin Law wrote:> On 4 June 2010 15:23, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> Jian Lin wrote: >>> At work, we have a situation where when >>> >>> � script/server >>> >>> is run, then all the controller code is cached. �This is to speed up the >>> development server. �But that will mean that whenever we change the >>> controller code, we need to restart the server. >> >> Yes, that''s normal behavior in development mode. > > I thought that was the normal behaviour in production mode, not > development.Right you are. I didn''t write the word I meant to write. :P> > ColinBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jian Lin
2010-Jun-05 11:54 UTC
Re: Can Rails cache a Controller "as long as code not change
Marnen Laibow-Koser wrote:>> foo.js?1273424325 >> >> which is to use the cached version as long as there is no code change, >> but recompile it when there is code change? > > Because it''s a different kind of caching. JavaScript caching simply > involves using the browser cache for included files, whereas controller > caching involves Ruby objects in memory on the server.I know that they are different kind of caching, -- now can''t the same principle be used? When newer, reload / recompile it -- when older, no need to reload or recompile. so when the controller code in cache is newer, then no need to re-compile. when it finds that the controller code is newer, then recompile it. by the way, what is this caching? I thought it is re-interpreted each time? So what is the caching for -- it is not byte code like in Python? -- 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.
Frederick Cheung
2010-Jun-05 14:35 UTC
Re: Can Rails cache a Controller "as long as code not change
On Jun 5, 12:54 pm, Jian Lin <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Marnen Laibow-Koser wrote: > >> foo.js?1273424325 > > >> which is to use the cached version as long as there is no code change, > >> but recompile it when there is code change? > > > Because it''s a different kind of caching. JavaScript caching simply > > involves using the browser cache for included files, whereas controller > > caching involves Ruby objects in memory on the server. > > I know that they are different kind of caching, -- now can''t the same > principle be used? When newer, reload / recompile it -- when older, no > need to reload or recompile. > > so when the controller code in cache is newer, then no need to > re-compile. when it finds that the controller code is newer, then > recompile it. > > by the way, what is this caching? I thought it is re-interpreted each > time? So what is the caching for -- it is not byte code like in Python?Caching is sort of the wrong word, because it implies that rails does something in order to achieve caching, whereas the opposite is true: rails'' code reloading is the extra behaviour. There have been attempts to make the code reloading stuff only reload what needs to be reloaded, see for example http://github.com/thedarkone/rails-dev-boost Fred> > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.