: Handling Page View for Images Site I want to know how sites like stackoverflow.com or imgur.com manage the page views of their article. i.e. once i view it and then no matter how many times
I want to know how sites like stackoverflow.com or imgur.com manage the page views of their article.
i.e. once i view it and then no matter how many times i refresh it.. the page view count won't increase.
I would also like to implement it for my image site and would also like to know when should i update views in database.
Thanks.
More posts by @Cooney921
2 Comments
Sorted by latest first Latest Oldest Best
Here's how I would do it:
First check that it looks like a real person using a browser and not a search engine bot (e.g. check the user agent string for "bot").
Store the IP address in a database with each visited page, for up to 24 hours.
On each page load, if this IP address has not viewed this page in the last 24 hours then add 1 to the view count.
This is normally handled using session variables. When the user enters the site for the first time, a session is created.
Every time you view view an article or a page, the site checks whether the id of the page is stored in the session variable. If it isn't, then the view is counted and the id stored in the session variable. Otherwise, the view count is skipped.
The way you implement this feature depends on the programming language you used to create your site (Ruby, Python, Java, PHP...).
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.