Jonathan Bennett

Fun Times with Caching

So I recently was working on a client project and ran into a problem with an admin report page being super slow only on production, oven though it had russian doll caching setup on it.

I checked that caching was enabled on production (Rails.application.config.action_controller.perform_caching == true), which it was.

Turns out, when the redis server had been provisioned on Heroku it had the max memory policy of noeviction. This means once the server was full, it wouldn’t add anything new to the cache, and Rails would swallow any errors and just do the slow normal render.

Switching the policy to remove the least recently used values, allkeys-lru, would clear up space and get things running smoothly again.