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.
The difficult part of any caching system is knowing when to clear the cache. (Indeed, there is a famous quote about this from computer scientist Phil Karlton: "There are only two hard things in Computer Science: cache invalidation and naming things.") The Webvanta system provides a variety of mechanisms for cache clearing, as explained in this article. If you want to build complex sites with good performance, it is critical to understand these options and use them properly.
The speed of a static page is determined by a variety of factors, including:
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 (e.g., the speed of the visitor's connection) or determined by the design of your site.
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 5 seconds or more. For such pages, it is critically important that you optimize the site to keep the page cached as much as possible.
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, choose Settings > Clear All Caches, or edit and save the offending page.
To provide your site visitors with the best possible performance, the cache is cleared selectively. In most cases, this happens automatically. 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:
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, edit the item type (via Database > Item Types) and open the metadata section by clicking on the banner of that name, if it is not displayed.
Under the label Associated Pages, you'll then see a list of all of the site's 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.)
Note: if you are using the legacy "standard" item types, you can set their associated pages by editing the item type via Settings > Link Types. If you are using the membership system with custom user profiles, you can set the associated pages at the bottom of the admin page for defining the custom user profile fields.
There are a few changes that do not automatically clear the cached content:
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.
Another case in which the cache is not automatically cleared, but the page content should change, is when you have date- or time-based conditions in your item iterators. In this case, you can use periodic cache clearing. See Periodically Clearing the Server-Side Cache for details.
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 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.
When you see pages that are "stale" (such as when you've changed images or config settings), clear the server cache by choosing Settings > Clear All Caches. 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 may want to view the main pages yourself to pre-fill the cache.)
You can clear the cache for a particular page by editing that page and saving it.
When you have time- or date-dependent content, or don't want the cache automatically cleared when database items are edited, you can set the cache to be cleared periodically, either for the entire site or for selected pages.
See Periodically Clearing the Server-Side Cache for details.