Page View Counter like the one here on StackOverFlow?
What is the best way to implement the page view counter like the one found开发者_运维百科 here on this site where each question has a "Views" counter using PHP and MySQL??
I think you should take a look at that discussion, which already covers what you're trying to do. Page Views counter using PHP and MySQL?
You would need to increment a counter in the database every time the page the page is loaded. In the url above, there was a specific table for this counter. But you can only add a "views" field in your post database and increment it the same way.
It depends on the amount of traffic your site is getting and in speed.
If you want scalability I'd use caching with a fixed expiration time set and increment values within cache and when cache will get expired a callback would transfer that number to MySQL database. This way things will be scalable and you will save lots of database calls hence speeding up responses.
But I can't advise you on caching in PHP since I'm on MS technologies. Others will provide answer to this.
精彩评论