Not Your Father's Visitor Counter
By Randal L. Schwartz
I am not a big fan of visitor counts. They aren't really accurate proxies and reloads can skew the count. And what does the visitor count communicate to the other visitors? They're either interested in the information or not. You don't hit a Web page, notice that the visitor count is over 22,435, and leave because too many people have been there!
In jest, I've created my "nonvisitor counter" (NVC). Every time someone reloads my home page, a random number from 1 to 99,999 is generated and the appropriate image (or text) is displayed. Aside from humor, this demonstration has little value; however, some of the tricks I used for it are applicable in other areas.
I use server-side includes (SSIs) to implement the NVC. The server (Apache, in this case) scans the document, looking for items like <!--# ... --> and replacing them with other text as the document is delivered to the requesting client (like a browser). The client never sees these lines of code because they don't appear on the browser when you view the source.
The code I edit looks like
Figure 1(a), where the hypothetical SSI directive "include virtual" causes the random_visitor_th CGI script to be executed and its output to be inserted in place of the SSI directive.