Open peppelinux opened 4 years ago
The lock manager would be implemented in Redis
# hit counter on page
r_head = dict(request.headers.items())
srcip = r_head.get("X-Forwarded-For") or \
r_head.get("X-Real-Ip", request.META['REMOTE_ADDR'])
but also see sessionid
...
There would be the need of a hit counter. Something already exists, like django-hitcount: https://django-hitcount.readthedocs.io/en/latest/overview.html
I think that a django-hitcount should not be used because of the real possibility to cache the pages (for huge loads). I'd like instead to implement a custom hitcount js based. Each time a user open a content (page or publication) a js in it will:
if the current uri path doesn't exists:
The API resource would be accessibile with something like
api/hitcounter/<app_label:str>/<model:str>/<pk:int>
Backed side a memcached/redis storage would be adopted with a key:value lifetime of N seconds. Each time a hitcount will be triggered API side, the backed would check if anothersessionid: uri
have been stored in the local memcached/redis, if not -> counter +1this would limit possibile resource abuses