caching - Rails Cached partial in layout is rendered twice -
I'm trying to cache partial which is presented in the layout. It is partly computationally expensive so I want to count it once. This controller is not specific, therefore normal piece caching does not apply. I have decided to use Rails.cache.fetch ('menu') instead of caching. Partially viewable content is provided here.
& lt;% Rails.cache.fetch ('Menu')%> Partial code ... & lt;% end% & gt; But when I do this it renders partially twice, for some reason it has stopped doing so in my development environment, so I tried and applied it Decided to I'm not so lucky with my production environment that partially prepares a menu that includes lots of records for the site to help improve navigation.
I tried to put a cache statement in the layout file basically, but then the layout was rendering twice
I recently removed a duplicate HTML for a jQuery Hack has been added, so that it "works" so far, but I'll work it properly. I do not want to go into the problem of installing some complex caching systems like radis, for which I need to run another server program. It will be redundant for the work. There should be something in the train that is well suited to cache parts of the layouts.
Should I try to completely separate something or is it a bug in the railways? Can I use a workaround if this is a bug?
I understand that instead of partially cashing in the scene, I have created a helpful method Provided partial comes.
#Applish a menu for the App Layout def menu Rails.cache.fetch ('menu') {Render: partial = & gt; 'All / menus'} and Then all the required lines in the layout & lt;% menu% & gt;
Comments
Post a Comment