Caching (2)
Now that I had caching at least working, it was time to get it the way I wanted it to work. Page caching turned out to be quite nice if you are just looking at the page as a visitor, but then after you login, you cannot edit anything, because the links just don’t show up. This is not that weird, since I was caching the whole page and invalidating the page just because someone logs in is a bit silly.
So, then I did some research and it turned out that action caching wasn’t the thing for me either, so I turned to fragment caching. After some initial confusion it turned out to be quite simple and fast.
I also tried to use memcached on my development machine at home. After installing Ruby-MemCache and it’s required libraries and adding the following line to config/environments/development.rb, it worked quite nicely:
ActionController::Base.fragment_cache_store = ActionController::Caching::Fragments::MemCacheStore.new("localhost")
So why use memcached instead of the default MemoryStore? Well, the default MemoryStore creates its own fragment store for each FCGI-process. So it would create more of a burden on your system then just using one central fragment store.