[Cover] [Previous Section] [Next Section] [Index]

Current chapter: Creating a Dynamic HDML Service
Section 23 out of 67 total sections , Section 3 out of 8 sections in this chapter


Tuning performance with digests

The UP.Link platform supports a multipart MIME format, called a digest, which allows you to send one or more entities--that is, HDML decks and the other content types listed in Valid content types--in a single message to the UP.Link server. This enables you to optimize use of the wireless network and make your service's user interface appear more responsive to the user.

If you know that the user will request multiple entities, you can send them all in a single response, instead of sending them individually as the user requests them. Because each HTTP request-response cycle involves a minimum time overhead regardless of the amount of data transmitted, sending a single response is normally much more efficient than sending multiple responses.


IMPORTANT     The exact size limit for a digest after the UP.Link server compiles it is 1492 bytes1. Because dynamic HDML services typically generate responses of varying length, it is recommended that you limit the size of the digests your service generates to 1200 bytes. To see the actual size of a compiled digest, load the digest in the UP.Simulator. The UP.Simulator prints the digest size to the Phone Information Window. If a digest contains fax content, the fax content is not counted toward the size limit; because the UP.Link server strips it off before sending the rest of the digest to the UP.Phone.



UP.Link digest format

The digest follows the standard multipart MIME format. The following is a high-level view of the format:


IMPORTANT     The order of the content entities is significant; the UP.Phone interprets the entities according to their order in the digest.

Each content entity must include the required Content-type header. For a content entity to be referenced by another entity, it must also include a Content-location header. The Content-location header must specify a URL relative to the digest URL.

For example, Figure 3-1 illustrates a simple digest containing two HDML decks. Note that when the user navigates from deck1 to deck2, the UP.Phone does not need to issue another request to the UP.Link server. It simply retrieves it from the digest, which is already in memory. This improves the performance when the user navigates between the decks.

FIGURE  3-1.     A digest containing two decks

The UP.SDK provides Perl and C libraries that make it easy to generate digests. The following sections describe how to use these libraries.


Generating a digest with the Perl libraries

To generate a digest with the UP.SDK Perl libraries, you follow these general steps:

  1. Include the Digest.pm and HDMLutils.pl libraries in your code. The libraries are provided in sdk_installdir/examples/apputils.
  2. Use the new() method to create a digest.
  3. Add decks and other entities to the digest.
  4. For example, to add a deck, use the addHDMLDeck() method; to add a cache operation, use addCacheOp().

  5. Use the OutputDigest() function to output the digest to standard output.

For example, the following Perl code generates the digest shown in Figure 3-1:


Generating a digest with the C library

To generate a digest with the UP.SDK C digest library, you follow these general steps:

  1. Include the digest.h header file in your code. The header file and the associated object files are provided in sdk_installdir/examples/source/digests.
  2. Use the DigestConstruct() method to create a digest.
  3. Add decks and other entities to the digest.
  4. For example, to add a deck, use the DigestAddDeck() function.

  5. Use the DigestSerialize() function to formulate the digest as a multipart MIME response and store it to a buffer.
  6. Print the buffer containing the serialized digest.
  7. Clean up by freeing the buffer and calling DigestDestruct() to destroy the digest.

When you compile and link your code, you must compile the digest.c file. The sdk_installdir/examples/source/digests directory includes a sample file (test1.c) and makefiles for Solaris SPARCworks/ProWorks (Makefile) and Visual C++ (test1.mak) that demonstrate how to use the library.

The following C code generates the digest shown in Figure 3-1:


[Cover] [Previous Section] [Next Section] [Index]

Current chapter: Creating a Dynamic HDML Service
Section 23 out of 67 total sections , Section 3 out of 8 sections in this chapter


1 Normally, compilation decreases the size of a digest. However, if the digest contains display text with numerous words and spaces, compilation actually increases the size. This is because each word is tokenized as a null-terminated string and each space is tokenized as a byte code.
Copyright © 1999, Unwired Planet, Inc. All rights reserved.