Full page caching in Rails part 2 - memcached and middleware

23-Oct-2020 3055
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.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle