Well, I'm thinking of making a Flash-like hit count with Ajax. When I say "Flash-like" I mean a hit counter that updates live, without page refreshes.
So, I'm thinking of making HTTP calls to to get the new hit count in the database. But I don't want it to be slow, and I don't want it to be a performance issue. So what I'm wondering is how to do this right.
I was thinking of making an Ajax call every 5 or 10 seconds. But then if I get 100 view within those seconds it would just jump to more 100 views. This I don't want, because I want to emphasize the point that it's moving up rapidly.
So, if make calls every 10 seconds but then with jQuery have the hit count move gradually up to the new number in a period of 10 seconds.
This sounds like a great idea. But is it a performance issue or do you have a better solution?
Flash-like hit counter with Ajax.
Moderator: General Moderators
Marketing purposes. And I want it.feyd wrote:I have to ask: why would you want/need such a thing?
EDIT
How does photobucket do it? The image counter at the bottom.
- Josh1billion
- Forum Contributor
- Posts: 316
- Joined: Tue Sep 11, 2007 3:25 pm
That sounds like a very cool idea, let us know if you finish it (especially if you plan to release the source
).
It does sound like it could take up a lot of resources, though..
What if you did this?
Visitor visits page:
It does sound like it could take up a lot of resources, though..
What if you did this?
Visitor visits page:
- 1. Database is updated.
- 2. Hit count is written as raw text to text file "hit_count.txt".. so the file will just say "383402" and nothing more, for example.
- 1. Hit counter script reads the new hit count from the text file
So making a call to the database requires a lot more then just reading a txt file? Currently I'm using one field in the database, not multiple. I have a registry database which has three columns: class, key and value. I store something like [Hit Counter] in the class and [global] for the key. The value, obviously, is the hit count. So all I do is update the value of this key in my registry table. Would the txt file be more efficient?
- Josh1billion
- Forum Contributor
- Posts: 316
- Joined: Tue Sep 11, 2007 3:25 pm