Hacker News new | ask | show | jobs
by o11c 329 days ago
Note that you can store longer state (at least 64K; more not tested) in the fragment (`location.hash`); obviously only the client gets to see this, but it's better than nothing (and JS can send it to the server if really needed).

For parameters the server does need to see, remember that params need not be &-separated kv pairs, it can be arbitrary text. Keys can usually be eliminated and just hard-coded in the web page; this may make short params longer but likely makes long ones shorter.

You absolutely should not restore state based on LocalStorage; that breaks the whole advantage of doing this properly! If I wanted previous state, I would've navigated my history thereto. I hope this isn't as bad as sites that break with multiple open tabs at least ...

2 comments

I've seem a largish company everyone here knows of, try this and have it fail, because of various weird client things, and also eventually run out of space in the hash. It's a neat hack but I wouldn't rely on it.
Oh boy, hashbangs are back.

The first one that comes to mind was twitter...

I think LinkedIn won the stuffedURLbufferOverflow Olympics back in the day.
They failed as a company?
Still around doing, eh fine. But they abandoned the url hash params with an id that references params on the backend (a mess!)
When people start using or buying your software you are going to quickly find out that 64K won't work
640K oughta be enough for everyone.