Home DemonstrationSignUPMember Area
 
 
 
Username    
Password  
 
Lost Your Password ? Signup Free
 
       
     
 
   
   
 
     
Click Here For Demo
Signup Now Free
Free Counter in One Click
     
  Free Counters Guide
About Tracking Referers
Counting Every Single Hit
History of Web Counters
How hosted free counters work
Counter Terms
     
     
   
   
 
 

Free Counter Guide:
Counting Every Single Hit

 

There are many obstacles to accurate hit counting. Two of these are caching.

For one, browsers may cache your web pages or page elements like CSS file or images. If so, the browser may bother to re-request the page information if the user views the page a second time.

The second problem is proxy server caching. Many people, especially AOL users or those in the military, access web sites from behind a proxy server that keeps copies of the pages that its users want and sends its users these copies without talking to your own web server. The proxy may make just own request for one of your pages and send copies of it to many users.

This may be a problem if you want to know for sure how much people are accessing your pages. Additionally, if you use impression-based advertising on your site (as opposed to click-thoughs) you may be getting fewer impressions than you could!

Fortunately, are many ways to overcome many possible unwanted caching issues by sending different HTTP headers along with your pages.

When a web server sends a web browser a web page, it sends it a hidden packet of information on top of the HTML code. These are the HTTP response headers, and they contain information from which browsers and proxy servers will try to tell if and for how long they can cache a given web page.

Here is an example of the HTTP headers that are sent along with a web page:

HTTP/1.1 200 OK
Date: Thu, 09 Mar 2006 16:54:26 GMT
Server: Apache/1.3.26 (Unix)
Last-Modified: Wed, 07 Jul 1999 17:48:36 GMT
Accept-Ranges: bytes
Content-Length: 45632
Content-Type: text/html

<HTML <META NAME="GENERATOR" CONTENT="Adobe PageMill 3.0 Win"&<TITLE>This is a really great site!</TITLE>
.....


The rest of the HTML code for this example page would follow the above.

There are a number of headers you can add or change that will discourage caching. You can modify these through your web server's configuration, and/or using the appropriate methods if you are using a server-side platform like CGI, ASP or PHP. Even if you are using a server-side language, you will still need to change your web server's configuration if you want to discourage caching of static HTML pages.

- Eliminate the Last-modified header. The presence of this header alone will often trigger caching. Also, if the page has not been modified in a long time, the browser or proxy server will assume that it will not need to re-request the page for a long time. Get rid of this header if you don't want that to happen.

- Set an Expires header to a date in the paste. The opposite of a Last-modified header, an expires header tells the browser after what time/date it should request a new copy (in theory). Setting this to a date in the past will make a server or browser that relies on this header never cache your page.

- Set a pragma: no-cache header. Though rarely used, this header is supposed to tell proxy servers not to cache a file. You might as well set it anyway.

- Set a Cache-control header to 'private'. Another rarely used header, some proxy servers will not cache your pages if this header is set. I've also been told that setting a second cache-control header with the following value will help: must-revalidate, post-check=0, pre-check=0

- Set the Vary header to '*'. This header tells servers according to what browser characteristics your web server will send different page contents. Usually this is set to 'Accept-encoding' if your web server is capable of sending compressed pages to browsers that support it, and/or 'User-agent' if you are sending modified pages based on the reported name of the requesting browser. Setting Vary to '*' means that your server intends to send different pages for every piece of information that it knows about users browsers. For proxy servers that pay attention to the vary header, this will make caching virtually impossible.

An example of a complete set of HTTP headers with these characteristics follows:

HTTP/1.1 200 OK
Date: Thu, 09 Mar 2006 16:54:26 GMT
Server: Apache/1.3.26 (Unix)
Expires: Wed, 07 Jul 1999 17:48:36 GMT
Cache-Control: private
Cache-Control: must-revalidate, post-check=0, pre-check=0
Pragma: No-cache
Vary: *
Accept-Ranges: bytes
Content-Length: 45632
Content-Type: text/html

<HTML <META NAME="GENERATOR" CONTENT="Adobe PageMill 3.0 Win"&<TITLE>This is a really great site!</TITLE>
.....


While it's not impossible that this page will be cached, it's far less likely.

 

© copyright webstat.net