HTTP Caching plugin
Plugin details
Documentation
Install the plugin:
ruby script/plugin install http://svn.codahale.com/http_caching/
An example using send_data:
def get_orders @photo = Photo.find(params[:id]) if_cached_before @photo.updated_at do send_data @photo.data, :type => @photo.mime_type, :disposition => 'inline' end end
Another example, this time using a simple RHTML view:
def get_user_profile @user = User.find(params[:id]) render_if_cached_before @user.updated_at end
A slightly more complicated RHTML example:
def get_orders render_if_cached_before Order.maximum(:updated_at), :layout => 'orders_feed', :action => 'all_orders' end
Or you can keep frequent refreshers from swamping your server:
def shiny_object if_cached_before 10.minutes.ago do @shiny_object = ShinyObject.complicated_database_call(:woo => :hah) end end
You get the idea.
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | (0 older versions) | Last edited by: hardway, 7 months ago

