Advanced Caching Options

The Webvanta platform now offers an option to clear cached pages very selectively. For sites with lots of database items and frequent updates, this can offer a significant decrease in average page load time.

To understand the changes, first we need a little background.

The Webvanta system includes a sophisticated server-side cache that keeps copies of complete HTML pages. This allows the system to deliver speedy response, even when complex database accesses are needed to create the page. The first time the page is ready by anyone on the web, the HTML is created and cached. Subsequent accesses don't require any action by the application or database servers and are therefore very fast.

The drawback of any caching system is that sometimes the cache needs to be cleared. When the data that underlies a page changes, the page must be regenerated on the next access.

In its default state, the Webvanta platform takes the most conservative approach, clearing all of a site's cached pages when any database item is changed. This minimizes the chances of a visitor seeing stale data.

You can significantly improve performance for sites with frequent changes by choosing the "associated pages" for each item type. (See Understanding Webvanta's Caching System for details.)

Making Cache Clearing More Selective

Even with the associated pages set, when you make a change to a database item, the detail pages for all pages of that type are cleared from the cache. Suppose, for example, you have a site with 1,000 articles. A single "article" page displays any article.

With the normal associated page behavior, all article pages are cleared from the cache any time any article is changed. This ensures that even if one articles includes, for example, a list of related articles, that content is always up-to-date.

If each article is independent, however, the vast majority of cache-clearing can be eliminated by setting the system to clear the cached page for only a single article, when that article is edited. The net result is that most pages stay cached nearly indefinitely.

Enabling Selective Cache Clearing

To enable selective cache clearing, create this setting:

admin.cache.restrict_synthetic_page_clearing_to_single_item

Set the value to a comma-separated list of item type names whose cached pages should be selectively cleared.

Clearing Multiple Item Pages

If you have more than one item page for a given item type, create this setting:

admin.cache.enable_alternate_item_page_hints

and set the value to true.

When you have enabled this feature, the item type definition page for the specified items types (Database > Item Types > click on edit icon) will have an additional field in the Custom Item Metadata section, called Alternate View Paths.

Enter into this field a comma separated list of additional pages that should be cleared when an individual CIT is updated. You can use the substitution pattern rules just like in a view page (e.g. /article/{{item}} or /article/perma_link_name.

Use With Care

On a large site with frequent updates, this feature can dramatically increase the likelihood that a page is delivered from the cache.

Suppose, for example, a site has 10,000 articles. Without setting up selective cache clearing, when you add a new article, or edit an existing article, all 10,000 article pages are cleared from the cache.

With selective cache clearing, nothing is cleared from the cache when a new article is added, and only one page is cleared when an article is edited.

Be aware, however, that if an article page (in this example) includes reference to any other articles, that information may be "stale" when an article is viewed.

Suppose, for example, the sidebar has a list of recent articles, or other articles in the same category. That list will not be updated as new articles are added or existing articles are edited, because changes to article B will not cause the cached page for article A to be cleared.

There are several ways to mitigate this issue, with the generally best approach first:

  • Load the related articles or recent articles section using an ajax call, so this content is refreshed every time the pages is loaded even though the rest of the page is cache. (A downside of this approach is that this content will not be seen by search engines.)
  • Set up a cache sweeper to clear the page cache daily. (The downside of this approach is that many pages may be cleared unnecessarily every day.)
  • Manually clear the cache periodically using Settings > Clear All Caches. (This gives you the most complete control if you can get by with only occasionally "publishing" the updated content.)