Understanding Webvanta's Caching System

Contents

Dynamic and Static Pages

The Webvanta system works hard to give you the best of both worlds: the performance of static pages, and the flexibility of dynamic pages.

All pages in a Webvanta site are dynamic, meaning that the information that defines them is stored in the database, and the page is created from that information. With dynamic pages, every change you make to the site's content, as stored in the database, ideally would be instantly updated on the site.

Creating pages from the database, however, takes more time than simply reading them from a disk drive. As a result, unless countermeasures are taken, a dynamic site is slower than a static site.

Webvanta provides the best of both worlds with a sophisticated caching system, which delivers static pages to your users almost all of the time, while keeping the pages as fresh as needed when you change the site's content.

The caching system stores a snapshot of each page that it displays, including the HTML, CSS, JS, and images. Unless you edit the site in a way that requires a change on a given page, that page will remain in the cache. All subsequent visitors experience the page as a static page, in terms of performance.

Static Page Speed

The speed of a static page is determined by a variety of factors, including:

  • Size of the HTML, JS, CSS files, and images
  • Number of different files required
  • Dependence on third-party systems (such as ad servers)
  • Bandwidth between the Internet and the end user's browser
  • Bandwidth between the server and the Internet

The only factor here that is under Webvanta's control is the last one: the speed between our servers and the Internet, which we take pains to keep fast. All of the other factors are either beyond control (the speed of the visitor's connection) or determined by the design of your site.

A good goal is that a static page should load on a "typical" user's browser in less than one second. This is not a problem for static pages as long as a typical user has broadband, the page doesn't include huge images, the JavaScript is well-behaved, there is little or no Flash content, and it doesn't depend on third-party services.

Dynamic Page Speed

Performance for dynamically-generated pages is much more complex. In the end, what gets delivered to the browser is indistinguishable from a static page, but because it is created by reading information from a database and then processing that information, additional time is needed to create the page.

Most dynamic pages from Webvanta sites are delivered in 2 to 3 seconds on a broadband connection. Large or complex sites may have pages that take 4 or 5 seconds.

Webvanta's Caching System

The caching system tries to deliver a cached version of each page whenever possible, so few users experience the longer page loads. As a system admin, you'll see them more often than any regular user, since you'll often be looking at the site immediately after you've made changes.

When you change the site's content, there's no way around the fact that all cached pages that contain the old information need to be cleared before they will show the new information. The next time that page is viewed, the cache is refreshed.

Webvanta's goal is to automatically clear all pages that are affected by any change you make, and to never clear a page on which nothing has changed. This is trickier than it sounds. Because of the great flexibility that Webvanta provides you to compose pages with templates, snippets, content regions, database content, and WebvantaScript, it isn't always easy for the system to know exactly what needs to be deleted, so it's important for you to know a bit about how the caching system works.

If you ever see content that seems out of date, first force your browser to do a complete page refresh (or clear the browser cache). If that doesn't do it, you can "hit the Big Red Button": the Clear button at the top of every page when you're logged in. You can also cleared cached content more selectively.

When the Cache is Cleared

To provide your site visitors with the best possible performance, the cache is cleared very selectively. In most cases, this happens entirely automatically. In some cases, if you supply some hints when setting up the site, you can significantly improve performance by making the cache clearing even more selective.

Cached content is automatically cleared in the following cases:

  • When you edit any page, the HTML file for that page is cleared.
  • When you edit a CSS, JavaScript, or XML file, that file is cleared.
  • When you modify the main navigation, all HTML pages are cleared.
  • When you modify a template, all pages that use that template are cleared.
  • When you edit or delete a comment, the page(s) on which that comment appears are cleared.
  • When you edit a snippet, all pages(s) in which that snippet is used, directly or indirectly, are cleared.

When the Cache is Not Cleared

There are a few changes that do not automatically clear the cached content:

  • Uploading, deletion, or modification of images, PDFs, or other files.
  • Changing config settings.

When you modify an image, it is difficult for Webvanta to know which pages to clear automatically, since the image may be selected on the page via a database request of some kind. To know whether or not to clear the cache, a large part of re-rendering the page has to be completed.

To err on the side of high performance for your site visitors, we do not automatically clear the cache when you upload images or other files. You can clear individual pages on the page admin screen, which minimizes the impact on your site's performance. Or you can just hit the Big Red Button.

Caching of Pages Using Database Items

Part of the Webvanta system's power is the flexibility of its database system. You can have as many database item types as you need, with whatever fields in each item, with many relationships between items, and you can display items of any type on any page.

This flexibility makes it difficult for Webvanta to automatically determine the minimum number of pages that need to be cleared whenever a certain database item is changed. If you do not change the default settings, then the cache for all pages (actually, just those that include WebvantaScript that accesses database items) is cleared when you change any database item.

You can make this much more selective by specifying which pages should be cleared when a database item of a given type is modified. For a large site that uses multiple item types, this customization can significantly improve performance by enabling more pages to stay cached when you modify database information. For example, if you have blog posts and a custom item type for projects, and you set up the limited cache clearing, then blog pages would not be cleared when you modify a project, and vice versa.

To access the cache settings for each item type, click the Database tab and choose the item type you want to access: Item Types (aka Custom Item Types) or Link Types

You'll then see a list of all pages. If no pages are selected, then all pages are cleared when an item of this type is changed. If you select one more more pages, then only those pages are cleared. (Use the usual control-click and shift-click actions to select multiple pages.)

Improving Snippet Performance

In the case of snippets, you can further increase your site's dynamic page performance by checking the "Safe to Cache" box when editing the snippet. When this box is checked, the snippet is not dynamically created each time it is invoked, but instead is cached in memory. For snippets that include only static content, or that reference database content that rarely changes, you should check this box. In general, you should not check this box for snippets that include WebvantaScript.

When you edit a snippet, its cached copy is always cleared, as are any pages the use the snippet.

Pages are correctly cleared even when they include snippets that include other snippets. If nested more than two levels deep, however, the third-level and deeper snippets will not trigger automatic page clearing.

Manual Cache Clearing

When you see pages that are "stale" (such as when you've changed images or config settings), you can simply hit the big red Clear button at the top right of every page. Be aware that when you do so, the next view of each page of your site will be considerably slower. By the second time it is viewed, however, it will be displayed from the cache at full speed.

You can clear all the content of a particular type (HTML pages, CSS, JavaScript, XML files) via a link at the top of the corresponding admin page.

For maximum control, you can also clear pages individually via the page admin screen, by clicking the lighting bolt. If you have a large site, and you just need to check one page, this has a much smaller impact on your site's performance than the Big Red Button.

Customizing Cache Behavior

It is possible to override many aspect of the cache system's behavior via config settings. If there's something you're looking for, please let us know.

Comments

2 comments

Updates to the caching system and to this article

From: Michael Slster, 12/01/09

Janet, thanks for pointing out these issues.

The problem of snippet changes not clearing pages automatically has been resolved.

There was also an issue with Clear All Caches that we have resolved, and we've renamed it Reset.

And we have added a genuine Big Red Button.

Cache Clearing Unclear

From: Janet, 12/01/09

Sorry -- This article is not clear. You say:

When you want to force the site to use the latest content, you have two choices:
========
"The big red button", which is really just a menu item: Site Admin > Clear All Caches
Selectively clear all HTML pages, a specific HTML page, all snippets, or files of a particular type (CSS, JS, XML)
========
I did the first one and the earlier rendition of the page was still there.

I do not get how you do the second choice.

Either way, it is slowing me up even more to use this system.

i understand what you are trying to accomplish but it seems, on my end, to create more work and a frustrating experience.

I have done everything I know to do and when I View Source, I am still seeing the old code that I have changed.

I renamed a snippet and edited it.

I then changed all references to it in the templates to the new name.

All I see is the old snippet name in View Source. (And, I did refresh and emptied cache in my browser, as well.)


Add Your Comments

(not published)