开发者

cache: [GET /] miss? dalli gem, memcached, rails 3.1, nginx, unicorn production environment

开发者 https://www.devze.com 2023-04-10 11:05 出处:网络
I\'m struggling to get a first application running in production. No matter what I do I get a basic 404 page and this in my unicorn log, no matter what I do:

I'm struggling to get a first application running in production. No matter what I do I get a basic 404 page and this in my unicorn log, no matter what I do:

cache: [GET /] miss
cache: [GET /something] miss

production.rb

 config.cache_store = :dalli_store, 'localhost:11211'
 #config.cache_store = :memory_store

Everything worked fine in development (sans the caching which was skipped in development afaik), and doublechecking I have all the syntax correct as per rails guides for setting up controller action caching, only nothing but error messages.

Can anyone give some pointers on perhaps why or what I'm missing? Works in development, but not on t开发者_开发问答he server I set up. I'm more than happy providing more info for getting this sorted out. This is a lot moving parts to coordinate, I'd appreciate any input.

edit:

I went in for some feedback from memcached, running it with all previous options and -B binary (plus -vv) it seems that the program doesn't even connect with memcached; memcached registers nothing while the program is running.

edit:

I went back to a local setup in development and production; caching works, memcached responds, the only difference is I'm not running through nginx/unicorn just webrick, but if that helps to pinpoint an issue I'm to be aware of perhaps that is of some use and a direction to pursue.

edit:

Going back to the server, and then running in development mode with cache configurations enabled:

config.cache_classes = true config.action_controller.perform_caching = true config.cache_store = :dalli_store, '127.0.0.1:11211'

It is obvious that rails is not connecting with memcached. There is nothing in the log about even attempting to connect with the cache, and memcache run with -vv shows no activity. If I go to the console I can manually connect as per the dalli basic cli instructions, hmmm. Just trying various options with memcached instances yields no response.

However, I can query memcached stats on an index page that comes up on each request where I've set it...though showing nothing in the rails log about accessing memcached.

edit:

wrestled through this, and found the error was unrelated....once I sorted through some asset pipeline issues for a misreferenced style sheet, everything seems to be running smoothly. A learning experience, at least.


Dalli is binary protocol only, so make sure your memcached server speaks binary protocol. For example, memcached should be started with:

memcached [...] -B auto [...]

Also, the memcached version must be >= 1.4.0.

UPDATE

These messages are generated by Rack::Cache being set to verbose logging mode and don't mean that anything is necessarily wrong. They're more of a reminder that you could do stuff like

expires_in 20.minutes
expires_in 3.hours, :public => true
expires_in 3.hours, 'max-stale' => 5.hours, :public => true

(in your Rails controllers) and then page caching may automagically work (and these messages would go away any time a page is rendered from the cache).


You can use Rails.cache.read('[key]') via heroku console to discover if it is working or not

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号