Network Mapping at a Glance, Part 3
Doing it visually with your own Perl script.
by Kent Cearley
Many browsers cache images in order to optimize performance. There's no straightforward way to defeat this mechanism for dynamically changing images, such as our network map. Some browsers will honor an HTTP header with an explicit Expired-date value, while others recognize a pragma: no-cache token, but in general, a reliable way to avoid having images cached is to load the page containing images from a script rather than via static HTML. As a result, our WebView application will now contain two separate scripts. The first will generate HTML for the main page and is opened with the browser, and the other will simply return the network map referenced in the <IMG> tag.
The HTML for the main page can be generated by the following webview.cgi script. Figure 2 shows how our Web page containing the network map might appear to the user.
#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print <<ENDHTML
<HEAD>
<TITLE>WebView</TITLE>
</HEAD>
<BODY>
<IMG ALIGN=right SRC=netimage.cgi>
<H1 ALIGN=center>WebView</H1>
<P ALIGN=center>Barebone Beginning...</P>
</BODY>
</HTML>
ENDHTML
The page is opened in a browser with the following type of URL:
http://www.somewhere.com/~networks/webview.cgi
The <IMG> tag in this generated HTML triggers a call to netimage.cgi. Netimage.cgi is the script that actually checks each node and displays the network map. Wrapping the <IMG> tag in the webview.cgi script ensures that the browser won't cache the page along with its associated image. Note that in Netscape you still have to turn on Auto Load Images before clicking the Reload button for this to work.
Now you're ready to write the code for the <IMG> script.
[Move on to the next part of the article]
Web Developer® Site Feedback
Web Developer®
Copyright © 2000 internet.com Corporation. All rights reserved.