|
Tutorial 2 - Counting Web Page Hits with SSI
|
|
The Common Gateway Interface:
|
|
CGI stands for common gateway interface. This is the
mechanism by which server side programs can work in peace
and harmony (we hope) with web pages. Ever been to a site
where they show the number of hits? Or that remembers
that you've been there before? These are likely to be
CGI applications.
|
|
In this article we're going to use Perl to write a CGI
application which will be run using a server side include
(or SSI) from a page on our website. The program will do
on the server what the program from article 1 did, i.e.
add one to a counter and keep the result on a file.
|
|
It will do this operation every time the webpage gets
viewed, so that the end result will be a file on the
server containing the number of page views or 'hits' that
this webpage gets.
|
|
Server Side Includes:
|
|
SSI is a facility provided by
the apache server,
and is a common way to do CGI programming on a website.
Simple to use, SSI can include text or execute a program
on your server before rendering the web page to a client.
For more details on SSI go to the NCSA (National Center
for Supercomputing Applications)
SSI tutorial.
|
|
In order to execute our counting program on the web we
have to somehow tell the server to run it; each time
the web page gets sent to a client. There are different
ways to accomplish this. I've chosen SSI as the first
method to do this. In the third tutorial we'll use
another means to count page hits.
|