dp152153 2012-03-19 14:12
浏览 77
已采纳

如何使用简单的缓存系统计算页面视图

I am using a really simple FAST caching technique. I just implemented this techniuqe and it is great.

I have a row on my database that counts page views. This is also a very simple technique.

$query_rs_update = sprintf("UPDATE table SET views = views+1 WHERE id = %s", GetSQLValueString($colname_DetailRS1, "int"));

I can not find a way to use this technique and COUNT the VIEWS at the same time. Since the Page is being Cached .. ?

Anyone have a better technique? Can you turn a Query to Javascript so it will work using Caching ?

Thanks!

  • 写回答

3条回答 默认 最新

  • doutuo8800 2012-03-19 17:06
    关注

    There might be specific reasons to do it way you're doing, but it's generally considered bad practice to track pageviews or activity via MySQL. Your two problems now are that pages are cached, and the tracking ability will be severely underpowered. For example, you'll be missing an ability to separate organic vs robot traffic.

    It's best to allow an independent, trusted and capable metrics vendor to do that tracking as they do it for a living - and they can provide a rich dataset to explore.

    Warning: check your host's TOS

    Note that some hosting companies explicitly forbid forms of 'performance tracking' for managed SQL uses in their terms of service (count increment might apply here, since it can alter index information.) Unless you're using InnoDB storage engine, the performance will always be bad because the table is locked for all reads until the update is finished.

    Use Google Analytics

    There are limitations to GA, but the positives are that:

    • CACHING: it bypasses any local caching schemas
    • EFFICIENCY: offloads tracking overhead resources onto the client
    • PRICE: it's free to use
    • FILTER: robot traffic is removed from human activity
    • BROWSE: reports can be neatly organized, shared and explored
    • WRITE: has virtual page tracking (so your unique Ajax-dynamic page interaction can still be tracked)
    • READ: there is an API you can use to retrieve the data; ex: most viewed (see http://www.electrictoolbox.com/google-analytics-api-php-class-most-popular-pages/)
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程