Created
August 26, 2011 07:01
-
-
Save marshluca/1172861 to your computer and use it in GitHub Desktop.
Rails Action Cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ListsController < ApplicationController | |
before_filter :authenticate, :except => :public | |
caches_page :public | |
caches_action :index, :if => proc do | |
!request.format.json? # cache if is not a JSON request | |
end | |
caches_action :show, :cache_path => { :project => 1 }, | |
:expires_in => 1.hour | |
caches_action :feed, :cache_path => proc do | |
if params[:user_id] | |
user_list_url(params[:user_id, params[:id]) | |
else | |
list_url(params[:id]) | |
end | |
end | |
end | |
# http://api.rubyonrails.org/classes/ActionController/Caching/Actions.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ListsController < ApplicationController | |
before_filter :authenticate, :except => :public | |
caches_page :public | |
caches_action :index, :if => proc do | |
!request.format.json? # cache if is not a JSON request | |
end | |
caches_action :show, :cache_path => { :project => 1 }, | |
:expires_in => 1.hour, :layout => false | |
caches_action :feed, :cache_path => proc do | |
if params[:user_id] | |
user_list_url(params[:user_id, params[:id]) | |
else | |
list_url(params[:id]) | |
end | |
end | |
end | |
# http://api.rubyonrails.org/classes/ActionController/Caching/Actions.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment