4 What happens to the network traffic?

Let’s say the squid cache is empty, and everything is configured correctly. Tom’s computer requests a image with the URL of http://www.racecars.net/arielatom.jpg. Because Tak set up Tom’s browser to use a proxy server, the request is not sent directly to the Internet. Instead, it is sent to the squid box in the apartment.

The squid box analyzes the URL request, and finds that its cache does not contain this entry. As a result, squid sends the real URL request to the Internet (through the firewall and on to the ISP). As the file (as a JPEG image) streams into squid, squid stores it locally and forwards it back to Tom’s computer. Note that this forwarding starts as soon as the first part of the file arrives the squid box. In other words, squid does not wait until the whole file is downloaded before replying to Tom’s browser.

Let’s say this is a huge file with incredible resolution. It’ll take about 10 seconds to download the whole thing. As the file is being downloaded, Harry, in his room, on his own computer, browses a web page that requests the same file. This request is, again, sent to the squid box.

This time, the squid box realizes that Harry’s request, http://www.racecars.net/arielatom.jpg, is an entry in the cache. Instead of firing up another request to the Internet, the squid box replies to Harry’s browser immediately with what squid has received up to this point. Consquently, at least for the initial part, Harry’s computer receives the image file as fast as the LAN and the squid box can pump data, not bound by the Internet connection speed.

Of course, when Harry’s browser catches up to the last bit (literally!) that the squid box has received from the host www.racecars.net, then it, too, will be bound by Internet speed. At that point, the squid box will feed both Tom’s computer and Harry’s computer at about the same speed simultaneously.

An hour later, Dick starts browsing, and ended up requesting the same picture. Because a 20GB hard disk is relatively large for caching purposes, the image is still stored on the squid box. As a result, Dick’s computer gets the entire image from the squid box without having to wait for any Internet traffic.

A month later, to their relief, Tom, Dick and Harry find that their monthly bandwidth usage is now below the red line. They all invite Tak over for a BBQ.