Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I agree with the overall JWT statements you made.

> This is the author's claim, but the code clearly DOES store data on the server, for the refresh token.

You're right, but I was making a different point about session IDs versus JWTs.

With session ids, each user request requires a server-side lookup to validate the session. For that reason, their ideal place would be something in-memory and that's what I was referring to with "data on the server".

While storing session IDs in a database is an option, in my case it would introduce noticeable latency because I self-host my projects on a cluster of Pis at home and even though I have a fast connection, a roundtrip to my external (I don't self-host it) database still takes a few milliseconds under low load.

JWTs allow me to avoid frequent server-side lookups. I can trust the client's data without hitting the database, except when issuing a new JWT - but even then, that happens every 2-3 minutes per user. While verifying JWT signatures and decoding claims does consume some CPU cycles, this overhead is minimal on my setup compared to the latency of database roundtrips.

Nothing against session ids, but I feel JWTs are better suited for my resource constrained setup.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: