Page caching
suggest changePage caching left Rails 4 and lives in the actionpack-page_caching gem. It stores one dynamic response as a static HTML file and serves that file on later requests. The README has the setup. Caching also has to be enabled (config.action_controller.perform_caching), which is off in development by default. Then call caches_page in the controller:
class UsersController < ActionController::Base
caches_page :index
end
Use expire_page to force expiration of the cache by deleting the stored HTML file:
class UsersController < ActionController::Base
caches_page :index
def index
@users = User.all
end
def create
expire_page :action => :index
end
end
The syntax of expire_page mimics that of url_for and friends.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents