XStandard Developer's Guide: Advanced Topics: Caching

The XHTML WYSIWYG Editor For Desktop & Web Applications

Caching

If you have configured the editor to reference external files, when the editor starts up, it downloads these files over the network. Since they are quite small, downloading a CSS, Styles or License file is no more resource intensive than loading a typical Web page into a Web browser. However, larger files such as a custom localization file or a custom buttons definition file can slow down the editor's start-up. To address this issue, files that need to be fetched over the network can be cached.

To enable caching, set the following param tag:

  1. <param name="EnableCache" value="yes" />

When the editor fetches files referenced by the following param tags, the files are stored in a cache:

  • CSS
  • EditorCSS
  • Styles
  • Localization
  • ScreenReaderXSLT
  • PreviewXSLT
  • Buttons
  • Icons
  • Placeholders
  • License

The editor uniquely identifies each file based on a case-sensitive URL to the file. When caching is enabled, at start-up the editor checks to see if a file with a given URL is already in the cache. If it is, the editor uses the cached version of the file instead of downloading the file again from the server. The editor automatically ensures that the cache does not exceed 200 files or 5 MB.

Caching does present a challenge however. When you update a file on the server, how do you tell the editor to use the new file instead of the old file kept in the cache? The easiest and most reliable way to do this is to modify the file's URL. For example, let's say the buttons.xml file is found at the URL:

  1. http://server1/buttons.xml

When the file is updated, modify the file's URL by appending a version number in a query string. For example:

  1. http://server1/buttons.xml?14

Each time you modify the file, simply increment the version number. For example:

  1. http://server1/buttons.xml?15

To automate the URL updating process, when your scripts are generating the param tags, a date last modified can be retrieved from the file and appended to the URL. For example:

12/3/2004 9:54:44 PM which when URL encoded looks like:

  1. http://server1/buttons.xml?12%2F3%2F2004+9%3A54%3A44+PM

The editor's cache can be cleared manually by selecting Editor > Clear private data from the context menu.

Screen shot of the context menu. Selected: Editor > Clear private data