Содержание

Symfony YAML Configuration Reference

The cache.yml configuration file

In this article we assume that you are familiar with The YAML Format and Configuration File Principles.

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.

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 disabled.

The default application configuration can be overridden for a module by creating a cache.yml file in the config/ directory of the module.

action_name:
  enabled:         <true | false>
  with_layout:     <true | false>
  lifetime:        time_in_seconds
  client_lifetime: time_in_seconds
  contextual:      <true | false>

Cache configuration options

action_name

If cache.yml is in the config/ directory of the module, then action_name key can specify one of the following:

If cache.yml is in the application config/ directory which describes the cache for the whole application, action_name key must be set to 'default'. Eg.:

default:
  enabled:      false
  with_layout:  false
  lifetime:     86400

action_name > enabled

Enables or disables the cache for the current scope. Possible values: <true | false> Default: false

action_name > with_layout

Determines whether the cache must be for the entire page (true), or for the action only (false). Possible values: <true | false> Default: false

action_name > lifetime

Defines the server-side lifetime of the cache in seconds (86400 seconds equals one day). Default: 86400

action_name > client_lifetime

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. Default: Same value as the 'lifetime' one

action_name > contextual

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. Possible values: <true | false> Default: false