read_fragment

read_fragment(key, options = nil) Instance Public methods Reads a cached fragment from the location signified by key (see expire_fragment for acceptable formats).

write_fragment

write_fragment(key, content, options = nil) Instance Public methods Writes content to the location signified by key (see expire_fragment for acceptable formats).

view_cache_dependencies

view_cache_dependencies() Instance Public methods

cache

cache(key, options = {}, &block) Instance Protected methods Convenience accessor.

etag

etag(&etagger) Instance Public methods Allows you to consider additional controller-wide information when generating an etag. For example, if you serve pages tailored depending on who's logged in at the moment, you may want to add the current user id to be part of the etag to prevent authorized displaying of cached pages. class InvoicesController < ApplicationController etag { current_user.try :id } def show # Etag will differ even for the same invoice when it's vie

expires_in

expires_in(seconds, options = {}) Instance Public methods Sets a HTTP 1.1 Cache-Control header. Defaults to issuing a private instruction, so that intermediate caches must not cache the response. expires_in 20.minutes expires_in 3.hours, public: true expires_in 3.hours, public: true, must_revalidate: true This method will overwrite an existing Cache-Control header. See www.w3.org/Protocols/rfc2616/rfc2616-sec14.html for more possibilities. The method will also ensure a HTTP Date h

expires_now

expires_now() Instance Public methods Sets a HTTP 1.1 Cache-Control header of no-cache so no caching should occur by the browser or intermediate caches (like caching proxy servers).

fresh_when

fresh_when(record_or_options, additional_options = {}) Instance Public methods Sets the etag, last_modified, or both on the response and renders a 304 Not Modified response if the request is already fresh. Parameters: :etag. :last_modified. :public By default the Cache-Control header is private, set this to true if you want your application to be cachable by other devices (proxy caches). Example: def show @article = Article.find(params[:id]) fresh_when(etag: @article, l

stale?

stale?(record_or_options, additional_options = {}) Instance Public methods Sets the etag and/or last_modified on the response and checks it against the client request. If the request doesn't match the options provided, the request is considered stale and should be generated from scratch. Otherwise, it's fresh and we don't need to generate anything and a reply of 304 Not Modified is sent. Parameters: :etag. :last_modified. :public By default the Cache-Control header is private,

send_data

send_data(data, options = {}) Instance Protected methods Sends the given binary data to the browser. This method is similar to render plain: data, but also allows you to specify whether the browser should display the response as a file attachment (i.e. in a download dialog) or as inline data. You may also set the content type, the apparent file name, and other things. Options: :filename - suggests a filename for the browser to use. :type - specifies an HTTP content type. Default