Implementing Railo Effectively As A Developer
By: Raymond Camden
A user posted an interesting question over on my forums that I thought I'd share with others.
I answered there but I'd like to get other opinions as well.
Here is the question:
I'm in the process of building a forum system as a means of trying out new things. Just came across an issue I hadn't really thought about with view tracking - what would you suggest is the best way to keep track of thread views so a user hitting refresh repeatedly doesn't artificially inflate the numbers?So what I recommended was based on the changes I made to BlogCFC recently.
presumably a DB table storing the thread id, user id (if recorded), IP address and timestamp of the view is a start - but I'm not sure how you would maintain that table to prevent it getting unwieldy, and i guess you'd only want to store the latest visit for any given thread for a user.
Originally, my "Views" column for blog entries would go up every time you viewed a blog entry.
You could sit there and reload all day long. (By the way, that issue still applies here, my own blog is a bit behind the released BlogCFC.)
I added a simple session variable that created a structure of viewed pages. I used a structure since I wanted a simple way to store, and check, for pages you had viewed before.
When you view a page now, I check that structure, and if this is a new page for you, I log a view. If it isn't, I do not log a view.
This was a rather simple fix, and it isn't perfect. BlogCFC simply counts views. It doesn't log them. So I can't say that Entry X got more views on Monday then it did on Tuesday.
Another problem - someone could block the session cookies and artificially inflate the views for an entry. But I'm not building the Pentagon here - so I think it was a reasonable solution.
So what have others done?
Comments
About The Author
Raymond Camden, ray@camdenfamily.comhttp://ray.camdenfamily.com
Raymond Camden is Vice President of Technology for roundpeg, Inc. A long time ColdFusion user, Raymond has worked on numerous ColdFusion books and is the creator of many of the most popular ColdFusion community web sites. He is an Adobe Community Expert, user group manager, and the proud father of three little bundles of joy.


