Sometimes
the operations involved in generating a Flash movie or a PDF document
can impose heavy loads on the web server, database servers or other
back-office servers.
In most situations the integrated data does not change frequently -
obvious examples are in the news industry (for example a daily news
site generated from a database only needs to access it once a day, as
all the requests for the same day will be equal), weather maps, distribution
maps (with update periods of 3 hours for example), product descriptions
(say for example, updated only weekly at most) and many others. On other
scenarios, media generation might not even be possible in real-time
- for example when doing video encoding of larger videos.
Turbine
allows for the caching of heavy media during a certain period of time
- during this period requested media will be served straight out of
the cache, without any other data-access or media generation effort.
The movie below will take a few seconds to appear when first requested
- but will display very quick within 1 minute thereafter (from the cache):
To
handle the above described scenarios, Turbine includes powerful caching
capabilities - during the period specified, media will be served straight
out of a server cache, requiring zero generation or data access effort.
The
script used for the above movie is:
<%@ Page language="c#"
%>
<%
// create the Turbine object
Turbine.Turbine7 Turbine = new Turbine.Turbine7();
//
no need for browsers to cache this page
Response.Expires = -1;
//
cache for 1 minute from now, if there was one at the cache serve
and exit
Turbine.Cache("++100", "flash");
//
do some heavy thing, just to take some time
for(int a=0; a<999999; a++){
int b;
b=a/987654321;
}
//
which .swf template file to use:
Turbine.Load("cache.swf");
//
now generate the movie to the web browser
Turbine.Generate("flash");
// the movie will also be added to the cache
now
%>
The
only difference on this script, in respect to a normal script is the
Turbine.Cache call, which requests that
the generated Flash movie be cached for 1:00 minute after the initial
request.