memcached - Why isn't caching activating in my Rails dev environment? -
i'm attempting setup caching in development using dalli , memcache.
i've installed memcached , can access rails console"
> rails.cache.write 'test', 'asdfasdf' cache write: test dalli::server#connect 127.0.0.1:11211 => 360287970189639680  > rails.cache.read 'test' cache read: test => "asdfasdf"   i've installed memcachier , dalli gems:
gemfile.rb
gem 'dalli' gem 'memcachier'   and i've updated development.rb instruct caching activate:
development.rb
config.action_controller.perform_caching = true config.cache_store = :dalli_store, '127.0.0.1'    however still can't seem make fragment caching work...
however if take 1 of view files , wrap contents in cache block doesn't seem affect page rendering:
- cache @page   %h1 @page.title   %p @page.contents   i don't believe caching
if check server logs there aren't fewer database calls. expect since cache key dependent on @page model, changes template not show in browser do. if alter contents , refresh browser updates.
what missing, why isn't caching?
edit - think perhaps explicit dependencies
in cache digests documentation there reference explicit dependencies , templates can't derived. think may problem, console showing messages such as:
18:39:10 web.1  | couldn't find template digesting: pages/magazine_header.html 18:39:10 web.1  | cache digest magazines/next_previous_nav.html: 5249e7d094aafe2365a097d8ca543dd1 18:39:10 web.1  | couldn't find template digesting: layout_partials/layout_partial.html 18:39:10 web.1  | cache digest pages/show.html: 314c806fcbb207d41137bc46f0856db0 18:39:10 web.1  | cache read: views/pages/199-20140614104931344003000/314c806fcbb207d41137bc46f0856db0 18:39:10 web.1  | read fragment views/pages/199-20140614104931344003000/314c806fcbb207d41137bc46f0856db0 (1.2ms) 18:39:10 web.1  |   rendered pages/show.html.haml within layouts/magazine (8.4ms)   i'm not sure how resolve investigating...
rails 4 isn't smart in figuring out template dependencies using implicit template rendering. it's mentioned in documentation linked. you'll need use special comment format in views:
<%# template dependency: pages/magazine_header %>   it can use explicit form of template rendering. rails able infer correct partials itself.
# change this: <%= render 'pages/magazine_header' %>  # this: <%= render partial: 'pages/magazine_header' %>   the news since rails 5.0.4 , 5.1.3, implicit template rendering got lot smarter. suspect using versions fix issue too.
Comments
Post a Comment