Hence, after first request, the same URL's response is deliver from cache, rails is no involved
3 caches:
page caching, action caching & fragment caching
page caching:
ex:
caches_page :test
action caching:
execute filter before return cached pages
ex:
before_filter :test_filter
caches_action :test2
turn on caching( in environment.rb) :
ActionController::Base.perform_caching = true
removing cache:
expire_page
ex:
expire_page :action=>test
expire_action:
ex:
expire_action :action=>test2
sweeper:
observe the model. When the model is changed, the sweeper expire the cached pages that
depend on the model
ex:
in app/models
class TestSweeper <>
observe Car
def after_create(car)
expire_car_page
end
end
in app/controllers
class Test <>
cache_sweeper :test_sweeper
end
the location to store cached pages:
ex:
http://localhost:3000/content/show/1 is stored in app/public/content/show/1.html
沒有留言:
張貼留言