iscache Element

Syntax

<iscache 
  status = "on" 
  type   = "relative" | "daily" // required
  hour   = duration_hr 
  minute = duration_min 
  varyby = "price_promotion"
  if     = boolean_expression // must be an expression that evaluates to a boolean value; cannot be a string
/>
Note: The <iscache status="off"/> statement is deprecated. This statement, which enabled you to disable page caching for the current response is no longer required. The default behavior (in the absence of a <iscache/> tag) is to disable page caching. A message in the deprecation log informs you about the usage of this tag. This log shows the code location per entry for all deprecation messages. When caching was disabled, so that the template or one of its included templates, recursively contained a page caching disabling directive; the caching could not be reenabled. This allowed template includes to prevent the caching of the entire page if the template's includes' content isn't cache-able.
Note: When specifying time, the 24-hour clock is used, meaning that 0 is equal to midnight, 1 is equal to 1:00 AM, 2 is equal to 2:00 AM, up to 2359, which is equal to 11:59 PM. If an absolute time is specified, it must be in GMT.
status = "on"

Before <iscache status="off"/> was deprecated, it was necessary to set <iscache status="on"/> to enable page caching. Now the presence of the <iscache/> tag implicitly enables page caching, and it is no longer necessary to set <iscache status="on"/>.

type = "relative" | "daily"
  • relative lets you specify a certain period of time, in minutes and hours, after which the page will be deleted from the cache.
  • daily lets you specify a specific time when the page is deleted from the cache
hour = duration_hr

Allowed data types: integer (0 to unlimited) or an expression.

If the type attribute is set to daily, the hour attribute value duration_hr must be an integer ranging from 0 to 23 when used with the minute attribute, and 0–24 if used alone. If type is set to relative, all integer values greater than 0 are valid (the default value is 0, meaning either the page is never cleared from the cache or only the minute attribute is relevant).

minute = duration_min

Allowed data types: integer (0 to unlimited) or an expression.

If the type attribute is set to daily, the minute attribute value duration_min must be an integer ranging from 0 to 59. If type is set to relative, all integer values greater than 0 are valid (the default value is 0, meaning either the page is never cleared from the cache or only the hour attribute is relevant).

varyby = "price_promotion"
price_promotion lets you mark a page as personalized. Salesforce B2C Commerce identifies unique pages based on a combination of price book, promotion, sorting rule and customization*, caches the different variants of the page, and then delivers the correct version to the user. If a page is personalized by means other than price book, promotion, sorting rule and customization, the page must not be cached, because the wrong variants of the page would be delivered to the user. For performance reasons, a page should be only marked with the varyby property if the page is personalized. Otherwise, the performance can unnecessarily degrade. See the following example.
Note: Customization here refers to A/B test segments with custom experiences. It doesn't refer to any other form of customization.

In order for the cache to work properly, the following must be different within the context of the page:

  • The complete set of active promotions.
  • The complete set of active product sorting rules.
  • The complete set of applicable price books.
  • The complete set of active ABTest Groups.

If there is no variance in these four items, you will not receive expected results.

if = "boolean_expression"
This must be a boolean expression. Anything else returns an error.

A page is either personalized or not personalized. If a page contains multiple <iscache/> tags, some with the attribute set and some with the attribute not set, the entire page is treated as personalized. If you use this tag in a template, the caching time is a randomized value between 1 second and 75 minutes.

Purpose

To improve the performance of the online storefront by caching pages and also enable developers to disable page caching.

The requested storefront page is retrieved from the cache without running the pipeline that invokes the template and generates the desired page.

Note: It isn't always possible or desirable to cache a page. For example, there are restrictions for caching pages that contain buyer-related data, such as address or basket information, or for pages containing framesets. See also Page Caching.

If you want a storefront page to be cached after the response is generated to the first request for the template, you must include the <iscache> tag in the template. The tag allows you to specify when the cached page should expire from the cache; after a fixed period or daily at a particular time, for example.

The tag can be located anywhere in the template. If the tag occurs several times in one template, the one set to cache off or the one with the shortest cache time is used as the cache setting for the resulting page. This is a safety mechanism, whereby content that isn't explicitly labeled for caching is never cached.
Note:

There are several issues to consider when using page caching in templates:

  • When using <iscache>, don't use session information or unexpected results might occur.
  • A page type must never use session information, but perform a remote include.
  • If you put an <iscache> in an included template, the entire template (calling and called) is cacheable.
  • Use <iscache> to control how long a page is cacheable. For pipeline responses, turn page caching off, and the template itself defines the duration.
  • Small dynamic snippets are not cacheable; but would take less time to update because they are small.

Examples

A page based on a template that contains the following line of code would expire from the cache after 90 minutes:

<iscache type = "relative" hour = "1" minute = "30">

A page based on a template that contains the following line of code would expire from the cache every day at 0630 hours (6:30 AM):

<iscache type = "daily" hour = "6" minute = "30">

A page based on a template that contains the following line of code would expire from the cache every day at 2330 hours (11:30 PM):

<iscache type = "daily" hour = "23" minute = "30">

If Attribute Example

{!searchModel.isPersonalizedSort()} lets you control if a page should be cached at all. Use this with Predictive Sort to control the caching of predictive pages at the template level. When this attribute is on a page, search requests that use a sorting rule with Predictive Sort are no longer cached. An example of using this attribute in a template is as follows:

<iscache hour=“2” varyby=“price_promotion" if=“${!searchModel.isPersonalizedSort()}”/>

Caching is deactivated when if returns true, and activated when it returns false. An error is thrown when it returns a non-boolean.

Varyby Example

We added the following line of code to a search result page.

<iscache type="relative" minute="30" varyby="price_promotion"/>

The search result page depends on availability information that might change over time, so we set the caching time to 30 minutes. The page also shows price and promotion information, which might differ by customer. To instruct B2C Commerce to account for this, we added varyby="price_promotion". With this added tag, a cached page appears if the customer has the same eligibility for prices and promotions.