Page caching

suggest change

Page 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.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents