Skip to content

Instantly share code, notes, and snippets.

@codeprimate
Created August 19, 2009 15:46
Show Gist options
  • Save codeprimate/170417 to your computer and use it in GitHub Desktop.
Save codeprimate/170417 to your computer and use it in GitHub Desktop.
# The CACHE_PATH Proc constant can be used by controller action caching
# Example Usage: caches_action :index, :layout => false, :cache_path => CACHE_PATH
# Override the CACHE_EXPIRATION constant within your controller to change the
# expiration time.
#CACHE_EXPIRATION = 5 #in minutes
CACHE_PATH = Proc.new{ |controller|
"#{Digest::MD5.hexdigest(controller.request.request_uri +
controller.request.format +
controller.session[:user_id].to_s) +
((Time.now - Date.today.to_time).to_i/60).to_f.divmod((CACHE_EXPIRATION || 5))[0].to_s}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment