Full page caching in Rails part 2 - memcached and middleware
23-Oct-2020 3118
In this follow up to a previous post, I'll show how to implement full page caching in a Rails app using memcached instead of Redis, and a middleware instead of Nginx to remove some dependencies and simplify the...In a previous post, I showed how to implement full page caching in Rails with Nginx and Redis. I have in the meantime changed my approach for DynaBlogger and I am now using a memcached cluster for the cache instead of Redis, and a Rack middleware to serve cached pages instead of Nginx. Nginx may be a little faster since it allows serving content directly from cache, bypassing Rails entirely, but there is a big advantage with the new approach: Rails and Nginx "speak" different algorithms when hashing distributed cache keys in a Redis or memcached cluster (as opposed to a single Redis/memcached instance), making it difficult to write cache entries with Rails and read them with Nginx. The Nginx approach still works just fine with a standalone Redis/memcached instance but it's not as scalable.
Full page caching in Rails part 2 - memcached and middleware #ruby #rubydeveloper #rubyonrails #caching #Rails #memcached #middleware https://rubyonrails.ba/link/full-page-caching-in-rails-part-2-memcached-and-middleware