Path

7x / documentation / ez publish / technical manual / 3.8 / features / view caching / configuring the view cache


Caution: This documentation is for eZ Publish legacy, from version 3.x to 6.x.
For 5.x documentation covering Platform see eZ Documentation Center, for difference between legacy and Platform see 5.x Architecture overview.

Configuring the view cache

The view caching mechanism is enabled by default. However, you probably want to turn it off during site development (otherwise any changes being made in your custom node templates will not be visible on the site until you clear the caches). This can be done by adding the following line under the "[ContentSettings]" section in the "site.ini.append.php" file of your siteaccess:

ViewCaching=disabled

Please note that it is strongly recommended to re-enable the view caching when development has finished. This can be done by changing it from "disabled" to "enabled":

ViewCaching=enabled

The CachedViewModes setting located in the "[ContentSettings]" section of the "site.ini" configuration file (or an override) controls which view modes the caching will be enabled for. The default value of this setting defines that view cache should be stored for "full", "sitemap" view modes and for the "pdf" view:

CachedViewModes=full;sitemap;pdf

If you need to disable view caching for a specific page, add the following line in the beginning of the template that is used:

{set-block scope=root variable=cache_ttl}0{/set-block}

 

This will set the global variable "cache_ttl" to zero for the current template. The "cache_ttl" variable contains the TTL (Time To Live) value as seconds. A value of 0 means that the result should not be changed. A value of -1 means that the view cache should never expire, see the example below.

{set-block scope=root variable=cache_ttl}-1{/set-block}

Roles

The cache files are different for dissimilar role combinations. This means that the templates can have conditions based on roles even when view caching is on.

User preferences

The following text describes handling of user preferences and the way the preferences of the current user are taken into account when generating content view cache.

For example, whenever the user performs the following actions using the administration interface:

  • Enabling or disabling the bookmark menu (+/-)
  • Adjusting the horizontal size of the content structure menu (small / medium / large)
  • Choosing the view mode (list / thumbnail / detailed) and "items per page" limitation (10 / 25 / 50) for the sub items window
  • Changing the visibility of different windows (Preview / Details / Translations / Locations / Relations)

...or sets any other user preference, the system executes the "preferences" view of the "user" module in order to save the selected value. The information about which preference has been changed is passed using view parameters:

.../user/preferences/set/<name_of_preference>/<value>

for example

http://my.com/myadmin/user/preferences/set/admin_left_menu_width/medium

After saving the selected value, the "preference" view of the "user" module will redirect the user back to the last accessed page.

If your templates of cached view modes have conditions based on user preferences, you should specify which preferences that are used together with the different view modes - this can be done using the CachedViewPreferences setting located under the "[ContentSettings]" section of the "site.ini.append.php" configuration file.

Example

Let's say that you are using prices in several currencies for your products and the "node/view/full.tpl" template is overridden for products in order to display prices in the user's preferred currency. If view caching is enabled for the "full" view mode, the system will store view cache files for the product view pages. If the cache is generated regardless of the preferred currency, when another preferred currency is chosen, the same product page that is being viewed will be returned (in other words, it will not change).

In order to avoid this, you need to specify the "user_preferred_currency" preference in the "CachedViewPreferences[]" array using "full" as an array key so that the cache will be stored for each possible preferred currency on your site. To do this, open the "site.ini.append.php" configuration file located in the "settings/siteaccess/example" directory (replace "example" with the actual name of the siteaccess) and edit it. If the "[ContentSettings]" section of the configuration file already contains something like

CachedViewPreferences[full]=<list_of_user_preferences>

then you will have to append a semicolon and "user_preferred_currency" at the end of the line, for example:

CachedViewPreferences[full]=admin_navigation_content=0;
admin_navigation_details=0;<...>;admin_bookmarkmenu=1;
admin_left_menu_width=13;user_preferred_currency=''

Note that this configuration line tends to be very long. It is simplified in the example above (a lot of settings were replaced with <...> in order to keep things short).

If the "[ContentSettings]" section does not contain a line that starts from "CachedViewPreferences[full]", create it:

CachedViewPreferences[full]=user_preferred_currency=''

Related siteaccesses

The RelatedSiteAccessList setting located under the "[SiteAccessSettings]" section of the "site.ini.append.php" configuration file controls which other siteaccesses the view cache should be cleared for when it is cleared for the current siteaccess. If this setting is not specified, the cache subsystem will use the AvailableSiteAccessList setting instead.

Please note that the AvailableSiteDesignList setting located under the "[VersionView]" section of the "content.ini" configuration file is no longer (from eZ Publish 3.8) used by the cache system. In 3.7 and earlier versions, it could contain an array of designs that would be touched when the caches were cleared.

Svitlana Shatokhina (23/10/2006 8:33 am)

Julia Shymova (29/02/2008 11:19 am)

Balazs Halasy, Svitlana Shatokhina, Julia Shymova


Comments

There are no comments.