4 ms·
To save the url length, why not hash all possible states and have the value of the variable in the query string refer to that?
by bgilroy26 11mo ago
To save the url length, why not hash all possible states and have the value of the variable in the query string refer to that?
- linked_list 11mo agoBecause a hash is by definition a one-way mapping, so then you'd have to keep a map of the reverse mapping hash -> state, which obviously gets impractical with state such as page index or search terms. Better just make two-way "compression" mapping
- yreg 11mo agoThey probably have meant something like base64 encode
- linked_list 11mo agoIf you base64 encode an ascii string it gets 33% longer
- poncho_romero 11mo agoThis is a viable solution, but as the article mentions, you lose intent and readability (e.g. seeing a query parameter for “product=laptop” vs. “state=XBE4eHgU”). And in general, it’s unlikely you’ll run into issues with URL length. Two to eight thousand characters is a lot!
- threetonesun 11mo agoI remember bouncing into this limit once in a project because we wanted to make a deeply customized interface shareable without a backend, and while on the site itself we didn't hit a URL limit, when someone shared it via some email clients it added it's own tracking redirect onto the URL which caused it to hit the limit and break.
- capecodes 11mo agobase64(zstd(big state))
- cyptus 11mo agoand where is the hash mapped back again?