| Author |
Topic Search Topic Options
|
iSec
Senior Member
Joined: 13 February 2005
Status: Offline
Points: 1140
|
Post Options
Thanks(0)
Quote Reply
Topic: Script to count # of times a page is viewed Posted: 14 January 2010 at 8:39pm |
|
Hello everyone,
I'm looking for a classic ASP-based code / script that counts the number of times a page is viewed. Just like here on the forum when a thread is viewed the # increases every time a user views that topic.
Example: This page has been viewed _______ times.
|
 |
123Simples
Senior Member
Joined: 08 July 2007
Location: United Kingdom
Status: Offline
Points: 1192
|
Post Options
Thanks(0)
Quote Reply
Posted: 15 January 2010 at 7:00pm |
|
Stat Counter http://www.statcounter.com/ will do it
|
|
|
 |
123Simples
Senior Member
Joined: 08 July 2007
Location: United Kingdom
Status: Offline
Points: 1192
|
Post Options
Thanks(0)
Quote Reply
Posted: 15 January 2010 at 7:00pm |
You can even then edit around that to say This Page Has Been Viewed (then stat counter code) times
|
|
|
 |
iSec
Senior Member
Joined: 13 February 2005
Status: Offline
Points: 1140
|
Post Options
Thanks(0)
Quote Reply
Posted: 15 January 2010 at 11:23pm |
|
That uses PHP and that's not what I'm looking for. I'm looking for an ASP-based script because the site I intend to use this on is of classic ASP.
|
|
"When it gets dark enough, you can see the stars"
-Charles A. Beard
|
 |
iSec
Senior Member
Joined: 13 February 2005
Status: Offline
Points: 1140
|
Post Options
Thanks(0)
Quote Reply
Posted: 15 January 2010 at 11:29pm |
I found one that accomplishes exactly what i asked for, and here it is if anyone needs it: http://www.psacake.com/web/iv.asp**Note: this is not listed on that page but you need to create a count.txt file and grant read/write access to it, for this script to work.
Edited by iSec - 15 January 2010 at 11:50pm
|
|
"When it gets dark enough, you can see the stars"
-Charles A. Beard
|
 |
dpyers
Senior Member
Joined: 12 May 2003
Status: Offline
Points: 3937
|
Post Options
Thanks(0)
Quote Reply
Posted: 16 January 2010 at 7:07pm |
|
On asp pages, also make sure that pages aren't being viewed from the browser or a proxy cache:
Set: Response.CacheControl="Private" This is to prevent proxy servers from caching the page. It's supposed to be the IIS default but some web hosts set it to Public by default to allow caching and reduce load on their servers.
Also set: Response.ExpiresAbsolute=#January 16,2010 16:00:00# Set this to the current date/time to ensure that the page expires from the browsers cache as soon as it's viewed.
These two commands change the HTTP headers for the page. Setting page expiration using HTML meta tags is not reliable across all browsers.
|
Lead me not into temptation... I know the short cut, follow me.
|
 |
iSec
Senior Member
Joined: 13 February 2005
Status: Offline
Points: 1140
|
Post Options
Thanks(0)
Quote Reply
Posted: 17 January 2010 at 12:03am |
dpyers, thanks for the tip... i needed that, especially the expiration one
|
|
"When it gets dark enough, you can see the stars"
-Charles A. Beard
|
 |
dpyers
Senior Member
Joined: 12 May 2003
Status: Offline
Points: 3937
|
Post Options
Thanks(0)
Quote Reply
Posted: 18 January 2010 at 3:26am |
|
Even changing the http header content sent by the servers isn't 100% reliable. Some ISP's and internet services offering a "faster" internet ignore the http header info as well and run their own cache's to server up pages quicker.
Counter services typically force the retrieval of an image or file from another ip address. often using a variable link. It adds another layer to what would need to be cached to replicate the page without actually retrieving it but large ISP's cache millions of pages/files.
Google has put a lot of pressure on ISP's to respect header info and the problem isn't as acute as it's been in the past. For most of us, missing a count or two is not a big deal. If it really matters to your site though, a strategy involving http_referer, cookies, remote images, and db updates can eliminate the misses. You won't see a good return on your investment in time to set it up, but for some sites, accuracy is more critical than for most sites.
On the flip side of the coin, some browsers can preload pages linked to the current page. You make get a hit, but no eyeballs actually viewed the page.
|
Lead me not into temptation... I know the short cut, follow me.
|
 |