Managing Application Resources
This topic describes best practices for managing application resources when developing a speech application for the Microsoft Speech Server (MSS) platform.
Resource Caching
The Speech Web Application Project Wizard creates a manifest file, manifest.xml, by default at the time a new project is created. MSS (more specifically, Speech Engine Services, or SES) reads this file to identify application resources to preload and cache. Preloading application resources improves performance and user experience.
For more information, see About Application Manifest Files.
The SES cache uses standard HTTP 1.1 cache control mechanisms as defined in RFC 2616, sections 13 and 14.
In accordance with the standard, caching of individual resources is controlled by a freshness lifetime, determined at the time the resource is downloaded. The freshness lifetime is based on two factors:
- Cache control headers, if present.
- A heuristic, if no explicit expiration time is provided.
The SES heuristic sets freshness lifetime to 10 percent of the resource age. Resource age is the difference between the download time and the last-modified time. The maximum freshness lifetime is one day. The minimum is one minute.
When the freshness lifetime expires, resources are considered stale. They are still cached, but their validity, determined by whether or not they are updated, is checked on the next access, using standard HTTP if-modified-since rules. A new freshness lifetime is determined, and they are updated if needed.
Note SES does not provide an if-none-match header when checking resource validity. The Web server determines whether a resource has changed based on the if-modified-since header and the file modification time, rather than the ETag of that resource. For information on ETags, see the section describing Header Field Definitions in the HTTP 1.1 protocol.
Cacheable Resources
Use HTTP headers to set the appropriate expiration time for cacheable resources that have specific expiration dates. For large resources, set an expiration date far enough in the future that these resources are updated only manually.
- For dynamically generated resources, use the HttpCachePolicy.SetMaxAge method to set the Cache-Control: max-age HTTP header.
- For static cacheable resources, use Microsoft Internet Information Server (IIS) administration on a directory or individual resource basis to set the expiration date.
Non-cacheable Resources
In order to avoid wasting memory or drive space, it is important to identify resources that are good for one use only and cannot be cached.
- For dynamically generated resources, the generating code should mark the resource as non-cacheable. For example, in C# use the HttpCachePolicy.SetNoStore method to set the Cache-Control: no-store directive.
- For static, non-cacheable resources, use IIS administration on a directory or individual resource basis to specify the resource as non-cacheable.
Enabling Prompt Databases
To enable prompt databases if Speech Application SDK (SASDK) is not installed on the Web server that hosts SALT pages, map the .prompts file type to the content type application/octet-stream. Procedures that describe this procedure for both Windows Server 2003 and Windows XP are in the topic Deploying Pocket PC Applications.
Deploying Grammars
If references to grammar files use file protocol URIs, these should be changed to HTTP protocol URIs when applications are deployed. File protocol references will fail when used in a staging or production environment.