action_controller.perform_caching = true
Many Rails plugins are available that modify or improve the standard caching functionality.
The Agile Web Development plugins database (http://agilewebdevelopment.
com/plugins) is the best place to look if you have a specific need.
Architectural Scalability | 177
Page caching
Page caching is conceptually the simplest form of response caching, and it is also the
fastest method. However, it is also the least flexible as it caches an entire page. When
a page is cached, on first access Rails stores the entire HTML response in a file whose
name corresponds to the path used to access the action. For example, the cached
response to the path /people/show/12 would be stored in RAILS_ROOT/public/
people/show/12.html. This enables the web server to answer subsequent requests
directly from the file instead of consulting Rails.*
Because the entire page is cached and served from the filesystem, page caching cannot
be used if even a small part of the page is dynamic. But it is this same characteristic
that makes page caching incredibly fast. Page caching is activated with the
caches_page class method:
class PersonController < ActionController::Base
caches_page :list, :show, :new
end
Once a page is cached in the filesystem, it must be manually removed if the information
becomes stale. Rails has a method, expire_page, which removes the specified
page from the page cache.
Pages:
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276