Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page Caching with Memcached

I am using Memcached in my Ruby on Rails 3 app. It works great with action and fragment caching, but when I try to use page caching, the page is stored in the filesystem instead of in Memcached. How can I tell Rails to use Memcached for page caching too?

In my development.rb file:

config.action_controller.perform_caching = true
config.cache_store = :mem_cache_store
like image 672
SZH Avatar asked Feb 24 '23 09:02

SZH


1 Answers

You cant. The equivalent of page caching in memcached is action caching, because the request must be served through Rails. Page caching is meant to bypass Rails, so the data must be stored in a file that can be served from the server, like Nginx or Apache. The reason page caching is so fast is that it does bypass Rails entirely. Here is what the Rails documentation says:

Page caching is a Rails mechanism which allows the request for a generated page to be fulfilled by the webserver (i.e. apache or nginx), without ever having to go through the Rails stack at all. Obviously, this is super-fast. Unfortunately, it can’t be applied to every situation (such as pages that need authentication) and since the webserver is literally just serving a file from the filesystem, cache expiration is an issue that needs to be dealt with.

You can find more information here.

like image 196
Pan Thomakos Avatar answered Mar 07 '23 08:03

Pan Thomakos