更好的方法来计算总页面访问量? [英] Better way to count total page views?

查看:114
本文介绍了更好的方法来计算总页面访问量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个电子商务网站,其中包含约2000-3000产品(no.can是增加了不远的将来)。所以我需要计算总页面访问量特定产品。

I am developing an eCommerce website which contains around 2000-3000 products(no.can be increase in near future).So i need to count total page views for a particular product.

我知道它可以通过只更新MySQL表上的每一个页面加载简单地做,但它不是正确的方式做到这一点,因为有一个人刚preSS的刷新按钮一而再再而三的页面访问量上升。

i know it can be simply done by just updating a mysql table on each page load but it's not the right way to do this because some one just press the reload button again again and the page views goes up.

所以,我希望做一个更好的方式,使总的看法没有。有点接近独特的/真正之一。

So i want to do it in a better way so total views no. somewhat closer to the unique/real one.

我只是想到了,我能做到这一点的3种方式的想法:\

i just came up with an idea that i can do it in 3 ways:\

1,使用的cookie 所以,如果我只是存储的cookie为每个产品再核对它的下一个唯一的访问则是可以做到的,但我认为这是没有更好的办法,因为如果不这样做总饼干长大然后它会影响每个页面请求我的网页的表现。

1.Using cookies so if i just store cookie for each product then check against it for next unique visit then it can be done but i think it's not the better way to do this because if no of total cookies grows up then it will effect my page performance on each page request.

2,采用会议我可以使用会话来存储数据,每个产品与访问者的身份,所以我可以跟踪它是一个独特的访问或重复one.But我认为会话数据的大小也增加,如果用户访问更多的&放大器;更多的产品,同一个会话。 因此,它是很好的使用会话用于此目的?

2.Using session i can use session to store data about each product and the visitor identity so i can track that is it a unique visit or a repeating one.But i think session data size also increase if a user visit more & more products with same session. So is it good to use session for this purpose?

3.使用DATABSE 我可以做一个表 PAGE_VIEWS 然后通过检查上次访问的,并通过匹配时间延迟更新计数数据IP地址和会话ID。

3.Use databse i can make a table page_views then update the count data by checking a time delay between the last visit and by matching the IP address and session id.

所以请建议我说,哪一种方法更好地使用和实施该方法的最佳途径。

so please suggest me that which method is better to use and the best way to implement that method.

我使用的 PHP(codeigniter 2.0.1)+ MYSQL

推荐答案

我会建议你创建一个新表来存储会话ID的变量,以及假设2小时的到期时间。您可以创建一个客户端服务器上的此ID的Cookie,这样你就不必反复使用MySQL查询。

I would suggest you to create a new table to store session ID variable, along with an expire time of let's say 2 hours. You can create a cookie with this ID on the client server, so that you don't have to use MySQL queries repeatedly.

在我的内网,我只在我​​的网页点击率表中创建一个 last_visitor_ip 列,我储存的最后一个IP的出现,让连续刷新不计入。 :)

In my intranet, I have only created a last_visitor_ip column in my web-hits table, and I am storing the last IP there, so that continuous refreshes are not counted. :)

这篇关于更好的方法来计算总页面访问量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆