Use HTML frames to reduce server traffic

The Web development community is polarized over the issue of using frames, with a majority speaking out against them. Web developers dislike frames for several reasons. For one thing, they cause a navigation nightmare and older browsers don’t support them. For another, some Web sites have historically imposed their framesets onto another site’s content.

Despite these valid concerns, frames can be useful—especially for reducing server traffic. Let's start with a brief explanation of how various frame types are used and then look at how they can ease server traffic. 

Types of frames

One type of frame is part of a frameset. It divides the browser window into subwindows. Each subwindow displays a different HTML document, which enables the developer to update only selected frames instead of the entire page. A navigation problem arises when the client clicks the browser’s Back button, but that can be handled by coding the JavaScript statement window.history.forward(1) on each page to disable the Back button.

An example of this type of frame is:
<frameset rows=”50%,*”
<frame src=”page1.asp” name=”frame1”>
<frame src=”page2.asp” name=”frame2”>
</frameset>

This example shows a frameset with two frames named frame1 and frame2. Even though the document.location of frame1 is page1.asp and the document.location of frame2 is page2.asp, these pages can affect each other and communicate with each other. For example, the JavaScript statement top.frame1.readyState allows the frame frame1 to determine whether the frame frame2 has completed loading.

The second type of frame is the inline frame, or iframe. Introduced in Microsoft’s Internet Explorer 3.0, inline frames can be embedded in an HTML document in much the same manner that an image is embedded. Inline frames let the developer embed an HTML document within an HTML document. Here's the syntax for an inline frame:
<iframe name="iframe" src="page3.asp" width=90 height=50></iframe>

On the surface, inline frames seem less useful in today’s business environment. But they do have some uses. One possible use would be to embed a code example in the middle of an article.

Reducing traffic with hidden frames

Now imagine a frame with a size of zero. The frame would in effect be hidden from the client. It sounds pretty useless, doesn’t it? On the contrary, when you're trying to reduce server traffic, a hidden frame can be a most useful thing.

One use of a hidden frame is to store information for later processing. As with most things, of course, this technique can be taken too far. Imagine trying to concurrently load 50 ASP pages, most requiring information retrieved from a database. Other pages required large images or absolutely tremendous Java Swing applets. In all fairness, once everything loaded, it was amazingly fast, but it took five minutes to load at Ethernet speed. Just imagine how long it would take at 56K. Although this implementation of the technique of loading objects to hidden frames left something to be desired, the idea was a sound one.

Frame of mind

Frames, like any tool, are neither inherently good nor evil. Most of the problems developers have with them result from the way frames have been misused in the past. As we've seen, when used correctly, HTML frames provide a way to reduce server traffic.