The Tangled WWW

11 AM March 4, 2004

My mum asked me how the hit counter on her home page works. I found myself at a loss for how I might explain it in a few short paragraphs of clear English.

An explanation shouldn’t be hard, since mum ranks well ahead of ESR‘s Aunt Tillie in the technology stakes. Before she retired, Mum was a COBOL/4GL programmer, she can happily and competently maintain a web-site and she also has a few other projects going on her PC too.

Never-the-less, the web’s melange of protocols, products and pragmatism makes a lay explanation of even basic techniques an interesting exercise.

Here is my best shot:

Hi Mum,

The counter on your front page is a picture generated by a program on one of your ISP‘s servers. The program keeps a count of the number of times it has generated a picture for your page and make a picture out of the number.

A ‘hit’ is jargon for request from a browser to a server. The hit-counter counts the number of hits on the hit-counter picture. Since a browser will request and display the hit-counter picture almost every time it requests and displays your home page, the number on the hit counter roughly the number of times your home page has been viewed.

I went to your home page and selected “View Source” from my browser menu, to look your page’s HTML. Near the bottom of the HTML is a line that looks like this:


This line is what causes the browser to go and fetch the hit-counter image. “lhancock_1.dat” is the name of your counter, which the program needs to know since the same program is used to display hit-counters on many different people’s pages.

You could put a hit counter on every page on your site. If you use the same counter name on every page, it will count the total number of requests to all pages. If you use different counter names on every page, it will count requests to each page separately.

You might have wondered why a hit counter is displayed as an image rather than as text. The reason is that it is difficult to get a web page to include a piece of HTML or text from another source, but straight-forward to get it to include a picture.

Hope that helps.

Glad to hear the new rooster is settling in well.

Love,
  Alan.

What do you think? Did I leave out something important? Is this explanation unnecessarily complicated? What would you do differently?

By alang | # | Comments (1)
(Posted to Software Development)

Comments

At 21:25, 04 Mar 2004 Ģirts Kalniņš wrote:

Smart counters try to understand when request comes from same session. So refreshing page should not increase counter and also revisiting page after 20 seconds.

Some clients does not display images, sometimes contents get requested by robots and such.

(#)

Add Comment




(Not displayed)






(Leave blank line between paragraphs. URLs converted to links. HTML stripped. Indented source code will be formatted with <pre> tags.)




© 2003-2006 Alan Green