Reputation: 677
I have a rails blog app that was working well.. However, I did some experiments with caching and in spite of having reverted to a previous version, something is still wrong here.
It seems that all pages are in cache or something like that (I have already cleaned my browser cache) as server logs do not show any get to database.
Any clue about how to solve this? Thanks!
Upvotes: 3
Views: 2436
Reputation: 34350
The problem is probably that you were using page caching like this:
class ProductsController
caches_page :index
def index
@products = Product.all
end
end
This actually creates a file called products.html in your /public directory, so instead of even hitting the Rails stack this file is rendered. Clearing your browser cache doesn't solve the problem because the file is stored on the server. There are two ways to expire this cache.
The first one is to create an action to clear the cache, and then call that action whenever you want to clear the cache:
class ProductsController
def clear
expire_page :action => :index
end
end
The second way to do this is to simply remove the .html file from your command line (bash):
rm public/products.html
Page caching is confusing for this reason. It's hard to tell when a page is actually cached and where it is stored.
P.S: If you were not using page caching then you can clear your entire memcached cahce or memory cache using this command:
Rails.cache.clear
Upvotes: 6