Databases Reference
In-Depth Information
Use cached data
Yes
URL in
cache?
Browser
cache
Inputs
Get URL
No
Store for
future use
Output
Get new
data
Get image from web server
Figure 10.10 Your local browser will check to see if the URL of an image is in a
local cache before it goes out to the web to get the image. Once the image is fetched
from a remote host (usually a slow process), it can be cached for future use. Getting
an image from a local cache is much more efficient.
Referential transparency allows functional programming and distributed systems to
be more efficient because they can be clever about avoiding the recalculation of
results of transforms. Referential transparency allows you to use a cached version of an
item that stands in for something that takes a long time to calculate or a long time to
read data from a disk filesystem.
Let's take a simple example, as shown in figure 10.10, to see how an image is dis-
played within a web browser.
By default, browsers think that all images referenced by the same URL are the
same “static” images, since the content of the images doesn't change even if you call
them repeatedly. If the same image is rendered on multiple web pages, the image will
be retrieved only once from the web server. But to do this, all pages must reference
the exact same URL . Subsequent references will use a copy of the image stored in a
local client cache. If the image changes, the only way to get the updated image is to
remove the original item from your local cache and refresh your screen or to refer-
ence a new URL .
By default your browser considers many items static, such as CSS files, JavaScript
programs, and some data files if they're marked accordingly by properties in the
HTML headers. If your data files do change, you can instruct your server to add infor-
mation to a file to indicate that the cached copy is no longer valid and to get a new
copy from the server.
This same concept of caching documents also applies to queries and transforms
used to generate reports or web pages. If you have a large document that depends on
many transforms of smaller documents, then you can reassemble the large document
from the cached copies of smaller documents that don't change and only re-execute
the transforms of smaller documents that do change. The process of using the trans-
form of documents from a cache is shown in figure 10.11.
This transform optimization technique fits perfectly into functional programming
systems and serves as the basis for innovative, high-performance website tools. As we
move into our case study, you'll see how NetKernel, a performance optimization tool,
is used to optimize web page assembly.
Search WWH ::




Custom Search