huacnlee / rails-settings-cached

Global settings for your Rails application.
Other
1.06k stars 202 forks source link

Understanding how caching works #101

Closed Svashta closed 8 years ago

Svashta commented 8 years ago

Sorry I am opening this ticket, but I would really like to understand how it all fits together. I am having major problems and I have currently no idea why it is happening.

In development environment everything works as expected. In production, however, i am getting really weird behavior.

I have a settings page where one can change the value of the setting (check boxes). When I hit update, than weird things are happening; when returned back to the page, values could be wrong, sometimes they are correct. Hit refresh few times and again values can be correct or not.

It is like the values are read from cache/db, updated - i can't really pinpoint why such a strange behavior. Same thing is happening for some DIVs i can show/hide via settings. When hitting refresh, sometimes they open and sometimes the are closed (no matter what i set as a setting).

So, I would like to understand when DB is hit, when Cache is read and when the cache is expired?

Maybe it could be something with the stack? I am using nginx/unicorn/redis.

Thank you very much!

Svashta commented 8 years ago

I've found where the problem was. Unicorn with more than one worker was causing my problems. Can't really understand why