This plugin is available through the Rails plugin mechanism as ''action_cache''>From the README:=== Action Cache update This is a drop in replacement for the Rails Action Cache. When this plugin is installed, the new behavior will take effect without any further configuration. All documentation for the Rails Action Cache is still relevant. === Features 1. Store cache entries as YAML streams so the Response headers from the original response can be returned with cache hits 2. Add a ''last-modified'' header to the response to get the client to use a get-if-modified request 3. If the client has the response we have cached, don''t send it again, send a ''304 Not Modified'' response to reduce data on the wire 4. Fix a bug in the original Rails code where responses other than ''200 OK'' are cached (since the headers aren''t cached in the original, all the clients would get is an empty ''200 OK'' response from subsequent requests) 5. Allow clients to provide their own implementation of the cache key for the actions, e.g. - environment.rb ActionController::Caching::Actions::ActionCacheFilter.fragment_key Proc.new {|controller| "AC:#{controller.request.host_with_port}:#{controller.params.sort.join('' :'').gsub('' '', ''-'')}" } 6. Allow an action to specify a Time To Live for the cached item. Set ''response.time_to_live'' to the number of seconds before this cached item will be expired. If not set, the default setting of ''never'' will be used and the item will only be expired by using the regular action cache expiry mechanism. def my_action @response.time_to_live = 10.minutes ... end === Performance If a client requests an action whose output hasn''t changed since their last request, the returning of a 304 response instead of the full response greatly reduces the load on the server. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060123/b774ce8e/attachment-0001.html
Very nice. Thanks Tom. I love how easy it is to just "drop in" :) Duane Johnson (canadaduane) http://blog.inquirylabs.com/ On Jan 23, 2006, at 12:25 PM, Tom Fakes wrote:> This plugin is available through the Rails plugin mechanism as > ?action_cache? > > > > > > From the README: > > > > === Action Cache update > > > > This is a drop in replacement for the Rails Action Cache. When > this plugin is > > installed, the new behavior will take effect without any further > configuration. > > > > All documentation for the Rails Action Cache is still relevant. > > > > === Features > > > > 1. Store cache entries as YAML streams so the Response headers from > the original > > response can be returned with cache hits > > > > 2. Add a ''last-modified'' header to the response to get the client > to use a > > get-if-modified request > > > > 3. If the client has the response we have cached, don''t send it > again, send a > > ''304 Not Modified'' response to reduce data on the wire > > > > 4. Fix a bug in the original Rails code where responses other than > ''200 OK'' are cached > > (since the headers aren''t cached in the original, all the > clients would get > > is an empty ''200 OK'' response from subsequent requests) > > > > 5. Allow clients to provide their own implementation of the cache > key for the actions, e.g. > > > > - environment.rb > > > ActionController::Caching::Actions::ActionCacheFilter.fragment_key > = Proc.new {|controller| > > "AC:#{controller.request.host_with_port}:# > {controller.params.sort.join('':'').gsub('' '', ''-'')}" > > } > > > > 6. Allow an action to specify a Time To Live for the cached item. > Set ''response.time_to_live'' to > > the number of seconds before this cached item will be expired. > If not set, the default setting > > of ''never'' will be used and the item will only be expired by > using the regular action cache > > expiry mechanism. > > > > def my_action > > @response.time_to_live = 10.minutes > > ... > > end > > > > === Performance > > > > If a client requests an action whose output hasn''t changed since > their last request, the returning of > > a 304 response instead of the full response greatly reduces the > load on the server.-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060123/55e8873d/attachment.html
Tom- Very nice! I''ve been watching your work on this caching issue with interest and this looks wonderful. Thanks! Cheers- -Ezra On Jan 23, 2006, at 12:57 PM, Duane Johnson wrote:> Very nice. Thanks Tom. > > I love how easy it is to just "drop in" :) > > > Duane Johnson > (canadaduane) > http://blog.inquirylabs.com/ > > > On Jan 23, 2006, at 12:25 PM, Tom Fakes wrote: > >> This plugin is available through the Rails plugin mechanism as >> ?action_cache? >> >> >> >> >> >> From the README: >> >> >> >> === Action Cache update >> >> >> >> This is a drop in replacement for the Rails Action Cache. When >> this plugin is >> >> installed, the new behavior will take effect without any further >> configuration. >> >> >> >> All documentation for the Rails Action Cache is still relevant. >> >> >> >> === Features >> >> >> >> 1. Store cache entries as YAML streams so the Response headers >> from the original >> >> response can be returned with cache hits >> >> >> >> 2. Add a ''last-modified'' header to the response to get the client >> to use a >> >> get-if-modified request >> >> >> >> 3. If the client has the response we have cached, don''t send it >> again, send a >> >> ''304 Not Modified'' response to reduce data on the wire >> >> >> >> 4. Fix a bug in the original Rails code where responses other than >> ''200 OK'' are cached >> >> (since the headers aren''t cached in the original, all the >> clients would get >> >> is an empty ''200 OK'' response from subsequent requests) >> >> >> >> 5. Allow clients to provide their own implementation of the cache >> key for the actions, e.g. >> >> >> >> - environment.rb >> >> >> ActionController::Caching::Actions::ActionCacheFilter.fragment_key >> = Proc.new {|controller| >> >> "AC:#{controller.request.host_with_port}:# >> {controller.params.sort.join('':'').gsub('' '', ''-'')}" >> >> } >> >> >> >> 6. Allow an action to specify a Time To Live for the cached item. >> Set ''response.time_to_live'' to >> >> the number of seconds before this cached item will be expired. >> If not set, the default setting >> >> of ''never'' will be used and the item will only be expired by >> using the regular action cache >> >> expiry mechanism. >> >> >> >> def my_action >> >> @response.time_to_live = 10.minutes >> >> ... >> >> end >> >> >> >> === Performance >> >> >> >> If a client requests an action whose output hasn''t changed since >> their last request, the returning of >> >> a 304 response instead of the full response greatly reduces the >> load on the server. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-Ezra Zygmuntowicz Yakima Herald-Republic WebMaster http://yakimaherald.com 509-577-7732 ezra@yakima-herald.com