Monday, February 8, 2016

Re: Implement page view count without using database for Hit

Thanks James,
We have consider database and updated sites using django-visits. Building such a full proof system will take longer time.

Regars,
Sonu

On Monday, February 8, 2016 at 2:29:46 PM UTC+5:30, James Schneider wrote:


On Feb 7, 2016 7:03 PM, "sonu kumar" <sonun...@gmail.com> wrote:
>
> Hi all,
> We have develop a site where we need to maintain page view count like SO, Quora,YouTube etc. Current approach is based on  number of retrieval using view this leads to problem to user that they are seeing that when a page is reloaded then count get's incremented see here http://www.job360.io/question-answer/cse/how-to-add-two-large-numbers
>
> How to tackle this problem, is there any exist which can do the work without managing database ?
>

I'm a bit confused as to why you would be averse to managing a database, assuming that you have an existing database for your users and other content.

If you don't want to manage the page hits yourself, you may look at something like Google Analytics to track it for you.

As far as the refresh question, I haven't researched this in detail, but as far as I'm aware, there is no standard method for requesting refreshes that all browsers follow, and it is difficult to determine whether a request is an initial content load request, or a refresh request without either the browser signaling the server with some type of request header, or some extensive tracking of requests with timers and other heuristics on the server side, and then of course your code has to catch all of those scenarios.

You're trying to merge the concept of a session with a request cycle. Unfortunately, humans think of web access more in terms of sessions, where the HTML, images, stylesheets, authentication, etc. are a single unit carried through while a user browsers a site, but HTTP is built to use a single content request cycle for each resource, independent of any other content request cycle. There are many tricks involved to provide the 'human' experience, like storing/retrieving session data for each HTTP request (which is why your web server process should provide images and stylesheets directly, not Django, so that those tricks are not invoked).

There's no easy answer to your question. It's possible that Analytics our a similar service will perform those database gymnastics for you in their optimized environments to try and remove refreshes from your counts, but you'd have to check with them.

You should also consider the guidelines for what you are counting as a 'hit' for your counter. Perhaps a refresh after 3 seconds shouldn't be counted, but what about a refresh after 45 minutes? What if the same user has multiple browsers open to the same site? What if robot crawlers access your page? Maybe you can filter those out via the reported user agent, but what if they spoof a real browser signature and request 10K hits? What if you have an SPA that polls the server for updates data?

Honestly, unless analytics takes care of this for you, it probably is not worth the extra effort of saving a couple dozen refresh requests. As your page reaches up into tens of thousands of hits, they'll probably become statistically insignificant anyway.

-James

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/01c4807a-9506-42ad-8ab7-a62a73ea3640%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment