Hacker News new | ask | show | jobs
by TheSoftwareGuy 2538 days ago
It does modify state on the server so I would think it should be a POST or something.

even better, they could do what reddit does with upvotes/downvotes, and store that information in the user's cookie, so that it gets sent with the next request to the server.

3 comments

I never realized Reddit did that. That's a really cool hack; like a poor man's version of Background Sync[1]. I guess the disadvantage of using cookies is that if you just click to vote and then close the tab, your vote might not be recorded for a long time.

[1]: https://developers.google.com/web/updates/2015/12/background...

I'm pretty sure they save it in the cookie and fire off a POST at the same time in an async thread and then don't check if the request succeeded. That way it's a backup if you're on crappy internet or the server was down or something.

The cookie isn't the only way the vote gets there.

That's a pretty big downside.
It's fine for Reddit's purposes. Randomly losing 10% of voting interactions wouldn't be a big deal for them. Of course, that wouldn't be ok for many other applications.
They probably figure that with the amount of clicking on threads that people on reddit do that the site will capture almost everything except for that very last page you upvoted on before you closed the tab and went to bed. However, you're probably getting on reddit soon anyway and the votes will be counted then.
Should be a PUT as the operation is idempotent.
Man that gave me some ideas regarding some users I have who have crappy internet connections ....