Server may change the presentation of the same document upon every
request, for example, putting on different advertising banners in the document.
This applet simulates what the server does in this case. For each request
that hits in proxy cache, the applet insert some advertising banners into
the cached document to create a new document. Proxy returns this new document
to client. Therefore, each time the client requests this document, it may
see different advertising banners in the document. Here
is an example applet.
Specifying the position of rotation banner in document
The positions for inserting rotation banners are specified in the cached
document with the following syntax:
<!-- Begin Rotate Banner Position <i>
-->
some other html lines
<!-- End Rotate Banner Position <i>
-->
Here, <i> represents a number, which
differentiates different positions for inserting rotation banner in the
document. When the cache applet is invoked, it scans the cached document
for the above pattern. If a pattern is matched, it replace the matched
pattern with one corresponding rotation banner.
Specifying the rotation banners
To know what rotation banner to be inserted into the document, the applet
requires the server to supply a specification file whose URL is the document's
URL appended with .ads.obj. For each position in the document, the
specification file specifies the rotation banners that may be inserted
in this position and the probablity of inserting each rotation banner.
The specification for one position in the file is as following:
Position <i>
<probability_1> <rotation_banner_1>
<probability_2> <rotation_banner_2>
... ...
<probability_n> <rotation_banner_n>
Here, <i> is a number specifying
the position. <rotation_banner_i> is
one possible rotation banner for this position. <probability_i>
is the occurence probability of <rotation_banner_i>
in this position. When the applet is invoked the first time, it retrieves
this specification file from the server and saves it as an object in ActiveCache.
When the applet runs, it first reads the specification file and insert
advertising rotation banners accordingly.
Seed object for generating random number
Each time the applet need to choose a rotation banner for one position,
it generates a random number and makes choice according to the specified
probabilities and the random number. That is, the choice made for one position
is dependent on the generated random number. The applet should generate
different number change on different invocations, so the random number
generator should use different seeds each time.
The applet creates a seed object in ActiveCache for itself. The seed
object contains a set of seeds, one seed for each position in the document.
When the applet starts running, it reads the seeds from the seed object.
Whenever it wants to generate a random number, the random number generator
uses the seed of the corresponding position, then the seed for this position
is changed so that it will be different next time. Before the applet finishes,
it saves the updated seeds to the seed object.