5 ms·
How I built ghit.me, hit count badges for GitHub
- akerl_ 11y agoHow does this deal with GitHub's caching of images? https://github.com/blog/1766-proxying-user-images https://github.com/blog/1766-proxying-user-images They refer to it as "proxying", but they also call out that it proxies using their CDN, which seems to imply there isn't a 1:1 relationship between user requests and hits on the backend server
- benwilber0 11y agoGithub's proxy[1] respects Cache-Control headers, so it will just pass through since we use Etags and Cache-Control: no-cache. [1]https://github.com/atmos/camo https://github.com/atmos/camo
- orf 11y agoHeh, someone should tell BitDeli[1]. They had to effectively shut down due to this, but if the fix is a simple as that then they will be hitting themselves. Edit: Would it not be possible/better to just serve the SVG image direct from nginx? There is a LUA plugin, or even some direct redis stuff you could use. 1. https://bitdeli.com/ https://bitdeli.com/
- techaddict009 11y agoInteresting find!
- benwilber0 11y agotheir analytics service still won't work since Github's camo proxy scrubs all cookies, referers, remote addrs, etc. edit: and regarding lua or nginx redis2, yes you could certainly do that. I happen to like the asynchronous nature of incrementing hit counters outside of the request cycle and just using nginx to serve the static badge files. But yeah there are a bunch of ways to do this.
- dookahku 11y agoI was about to post the exact same question as parent. I made a similar application to keep track of who was looking at my github repos. This is very helpful info! Thanks!
- jafingi 11y agoIf people fork/clone the repo, then wouldn't it also update the count on the main repo?
- Khao 11y agoBack to geocities websites with hit counters! I like how it was implemented though, I simply hope I won't start seeing this everywhere from now on because it doesn't add anything to a repo to have that badge.
- jlarocco 11y agoThe only thing missing here is some tacky, irritating animation, but I've even seen that being rediscovered in some recently posted articles...
- dougifresh94 11y agoThis got rate limited by github's API...
- deleted 11y ago[deleted]
- zeeshanm 11y agoIf anyone's trying to use ghit.me - beware that api rate limit from github is preventing the tool from working. May be, try again: { "message": "API rate limit exceeded for 107.170.25.70. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)", "documentation_url": "https://developer.github.com/v3/#rate-limiting" }
- rb2k_ 11y agoIf you ever wanted to filter by IP so you don't end up with tons of duplicates, it would be a nice usecase for the native hyperloglog support in Redis: http://antirez.com/news/75 http://antirez.com/news/75 http://redis.io/commands/pfadd http://redis.io/commands/pfadd http://redis.io/commands/pfcount http://redis.io/commands/pfcount
- zimbatm 11y agoYou can't, image urls on github are rewritten to be fetched trough a proxy.
- btym 11y agoCron? Syslog? Seriously? This could, in real-time and fewer lines of code, just directly get and increment a counter...
- benwilber0 11y agoyep it's a pretty trivial task and there are a lot of ways to do it. i like just serving static files and incrementing hit counts outside of the request.
- hfaran 11y agoFor anyone that is unaware, "hit count" functionality has been present in GitHub for at least several months. If you're the owner of a repository, you can view it at https://github.com/<username>/<repo>/graphs/traffic https://github.com/<username>/<repo>/graphs/traffic which gives you a breakdown of visitors, clones, referring sites, and which pages within your repository are popular.
- lell 11y agoIs there a way to make this cover a period of >2 weeks? I can only see 2 weeks of traffic for my repos.
- boomeasy 11y agonice. I just added it to my hackernews chrome extension repo: https://github.com/boomeasy/hnlinks https://github.com/boomeasy/hnlinks perhaps it will reach double digits by next year :-)