The cache.yml Configuration File
The ~cache.yml~ configuration file describes the cache configuration for the
view layer. This configuration file is only active if the
cache setting is enabled in settings.yml.
The configuration of the class used for caching and its associated configuration is to be done in the
view_cache_managerandview_cachesections of thefactories.ymlconfiguration file.
When an application is created, symfony generates a default cache.yml file
in the application config/ directory which describes the cache for the whole
application (under the default key). By default, the cache is globally set
to false:
---
default:
enabled: false
with_layout: false
lifetime: 86400
As the
enabledsetting is set tofalseby default, you need to enable the cache selectively. You can also work the other way around: enable the cache globally and then, disable it on specific pages that cannot be cached. Your approach should depend on what represents less work for your application.
As discussed in the introduction, the cache.yml file benefits from
the configuration cascade mechanism,
and can include constants.
The
cache.ymlconfiguration file is cached as a PHP file; the process is automatically managed by the ~sfCacheConfigHandler~ class.
The default application configuration can be overridden for a module by
creating a cache.yml file in the config/ directory of the module. The main
keys are action names without the execute prefix (index for the
executeIndex method for instance). A partial or component can also be cached
by using its name prefixed with an underscore (_).
To determine if an action is cached or not, symfony looks for the information in the following order:
a configuration for the specific action, partial, or component in the module configuration file, if it exists;
a configuration for the whole module in the module configuration file, if it exists (under the
allkey);the default application configuration (under the
defaultkey).
An incoming request with
GETparameters in the query string or submitted with thePOST,PUT, orDELETEmethod will never be cached by symfony, regardless of the configuration.
~enabled~
Default: false
The enabled setting enables or disables the cache for the current scope.
~with_layout~
Default: false
The with_layout setting determines whether the cache must be for the entire
page (true), or for the action only (false).
The
with_layoutoption is not taken into account for partial and component caching as they cannot be decorated by a layout.
~lifetime~
Default: 86400
The lifetime setting defines the server-side lifetime of the cache in
seconds (86400 seconds equals one day).
~client_lifetime~
Default: Same value as the lifetime one
The client_lifetime setting defines the client-side lifetime of the cache in
seconds.
This setting is used to automatically set the Expires header and the
max-cache cache control variable, unless a Last-Modified or Expires
header has already been set.
You can disable client-side caching by setting the value to 0.
~contextual~
Default: false
The contextual setting determines if the cache depends on the current page
context or not. The setting is therefore only meaningful when used for
partials and components.
When a partial output is different depending on the template in which it is
included, the partial is said to be contextual, and the contextual setting
must be set to true. By default, the setting is set to false, which means
that the output for partials and components are always the same, wherever it
is included.
The cache is still obviously different for a different set of parameters.
インデックス
Document Index
関連ページリスト
Related Pages
Introduction
The YAML Format
Configuration File Principles
The settings.yml Configuration File
The factories.yml Configuration File
The generator.yml Configuration File
The databases.yml Configuration File
The security.yml Configuration File
The cache.yml Configuration File
The routing.yml Configuration File
The app.yml Configuration File
The filters.yml Configuration File
The view.yml Configuration File
Other Configuration Files
Events
Tasks
Appendix A - License
日本語ドキュメント
Japanese Documents
2011/01/18 Chapter 17 - Extending Symfony
2011/01/18 The generator.yml Configuration File
2011/01/18 Les tâches
2011/01/18 Emails
2010/11/26 blogチュートリアル(8) ビューの作成
リリース情報
Release Information
- 2.0 : 2.0.10(2011/02/06)
Symfony2日本語ドキュメント - 1.4 : 1.4.16(2011/12/13)
Changelog
