i was wondering what the best way is to implement a hit counter for articles, products, etc. Now if someone visits the page the counter just adds one in the database. If someone refreshes the page it counts continuously, misleading results, and unnecessary reads, writes.
I was thinking of storing their ip, but i don’t know how to model this in mysql. If i make a db record for each hit it will be enormous.
I have read this article:
How to write an efficient hit counter for websites
The best answer was using a log and then update this log to db. But then again.
What is the best way to determine a new hit, is this with IP or another variable. And what is an acceptable amount of time to log the hit of particular user again.
Any other types of implementations are welcome too.
You could also just store the IP address and the time that you first logged it, and only increment if the time has been long enough, perhaps 30 minutes, then also increment the time related to the IP address.