Fetching and caching resources for improved performance

You can improve the performance of voice applications by using a combination of fetching and caching to prime the cache with referenced audio, script and grammar files before your application starts. To do this, create a VoiceXML application root document that contains a form that will never be visited. In this form, specify the audio, script and grammar tags that will be referenced by the application. the form should reference the appropriate fetching properties described by the VoiceXML specification, for example <property name=“grammarfetchhint” value=“prefetch”/>. It is important to note that the default behavior is to prefetch all resources except for documents. If certain resources can not be cached or expire immediately, applications should disable caching for these resources (using property or attribute names) to improve system performance.

Here is a two-document application illustrating the preloading of grammar for customer inquiries on laptop computers:

Application root document (preload.vxml)

<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml" xml:lang="en-US">
 <form id="loadgrammar">
  <grammar src="laptops.grxml" type="application/srgs+xml"
           fetchhint="prefetch" scope="document"/>
 </form>
</vxml>

Main document (main.vxml)

<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml" xml:lang="en-US"
      application="preload.vxml">
 <form id="greeting">
  <block>
   <prompt>
    Welcome to Laptops at Your Fingertips. At any time, you can say
    help or stop.
    <break time="large"/>
   </prompt>
   <goto next="getModel.vxml"/>
  </block>
 </form>
</vxml>

When the first document (main.vxml) in the Voice application is loaded, the application root document (preload.vxml) is also loaded. The VoiceXML browser loads the referenced grammar file (laptops.grxml) and stores them in the cache.

Note: The techniques shown above should only be used for a small number of resources that are critical to the responsiveness of the application. The number of prefetched audio files (or similar resources) should be limited to no more than 20–30, fewer if the files are large.

Viewing or expiring VoiceXML cache contents

You can use the dtjcache command to display or expire contents of the Blueworx Voice Response VoiceXML cache. You can select one or all documents or voice prompt files in the cache to expire. New versions of any expired contents will be fetched when an application next requests their use from the cache. Content in the process of being loaded cannot be expired until fully loaded. See dtjcache script for details.

Creating multiple VoiceXML 2.x cache directories

By default, Blueworx Voice Response creates only one VoiceXML 2.x cache directory for use by all application nodes in a Java and VoiceXML environment. However, it is possible for each node to use its own directory, which can lead to performance improvements.

To configure each node to use its own cache directory, complete the following steps:

  1. When logged in as dtuser, stop the Java and VoiceXML environment from the command line by typing:
    dtjstop
    dtjshost -exit
  2. Type cd $DTJ_HOME/native/aix
  3. Using a text editor, open the configuration file default.cff for editing. For each application node (or even the voice response node) that you want to use its own cache directory, add the following line to the application NodeName stanza:
    JavaCommand=javaexe -Dwvr.vxml2.cachedir=directory
    (where javaexe is name of the Java executable (for example: /usr/java14/jre/bin/java), and directory is the absolute path of the cache directory you want to use.
    If you already have a JavaCommand line in default.cff then simply add
    -Dwvr.vxml2.cachedir=directory
    to the end of the JavaCommand line.
  4. Save the file.
  5. Verify that the changes are valid, then update config.cfd by running the dtjconf command.
  6. Restart the Java and VoiceXML environment by typing:
    dtjshost
    dtjstart
    The new cache directory is created automatically if it does not already exist.

Increasing the grammar cache size

To increase the size of the grammar cache:

  1. Open configuration file $DTJ_HOME/dtj.ini in an ASCII editor.
  2. Modify the value set for the configuration parameter wvr.vxml2.grammar.memcachesize to an appropriate higher value. The default value is 10000 KB.
    For example, to increase the value to 20000 KB, modify the line in dtj.ini to read:
    wvr.vxml2.grammar.memcachesize=20000
  3. Save the dtj.ini file.