MySQL“更新”延时 更真实地统计在线视频观看次数
我正在为房地产网站创建一个视频嵌入页面,用户可以在其中观看给定房屋的视频游览。 没有其他原因访问该特定页面,因此我想我可以使用简单的 MySQL 更新对该家庭行的“视频视图统计”列进行更新,每次加载页面时都会更新views=views+1。
这很容易,但我想给出尽可能真实的“视图”计数,所以我试图想出一种方法,仅在页面加载一定秒数后才计算该视图(例如,30)。
关于处理时间方面的好方法有什么想法吗? 如果可能的话,我想避免使用 JavaScript,但如果处理得足够简单,我也愿意。
I'm creating a video embed page for a real estate site, where a user can go to watch a video tour of a given home. There is no other reason to visit that particular page, so I figured that I could use a simple MySQL Update to a "video view tally" column for that homes's row, which will update views=views+1 each time the page is loaded.
That's easy enough, but I want to give as realistic a "view" count as possible, so I'm trying to come up with a way to have that view tallied ONLY once the page has been loaded for a set number of seconds (say, 30).
Any thoughts on a good way to handle the timing aspect? I'd like to avoid javascript, if possible, but I'm open to if it it's handled simply enough.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,您知道页面是否仍处于活动状态的唯一方法是让客户端技术(如 JavaScript)告诉您它是活动的。
您可以添加一个不直接查看的“计数器”页面,而是在 30 秒页面计时器到期后通过 JavaScript 访问。 JavaScript 访问该页面的行为将触发计数器逻辑。
Unfortunately the only way you will ever know if the page is still active is to have a client-side technology (like JavaScript) tell you that it is.
You can add a "counter" page that isn't meant to be viewed directly, but instead is accessed via JavaScript after a 30 second page timer has expired. The act of JavaScript accessing that page will trigger the counter logic.