config.action_controller.page_cache_directory = RAILS_ROOT + "/public/cache/"
But sometimes you may need to add something special to the path on fly, when the controller is working. Say a language prefix or so. And you can do so in a nice one-line patch. You should overload the 'cache_page' method (not the 'caches_page' one), like that
def cache_page(content=nil, path=nil)
super content || response.body, path || (@language_name + request.path)
end
And you won't need to touch anything else, case all your controller caching settings will eventually call the method. Just notice, that the method should be public. And don't forget to add your hacky prefix to your sweepers.
That's pretty much it.
No comments:
Post a Comment