I'm looking to store cookie data in a compact form.
Is there such a thing as a compression algorithm that produces URL safe output? Currently my approach is
String jsonData = GSON.toJson(data);
byte[] cookieBinaryData = jsonData.getBytes("UTF-8");
byte[] cookieSnappyData = Snappy.compress(cookieBinaryData);
String cookieBase64Data = new Base64(true).encodeToString(cookieSnappyData);
From this cookieBase64Data
is the one stored inside the cookie.
I would be happy to skip the Base64 hop.
How much are you saving by doing this? Is it worth it?
How about just saving an ID in a cookie and then looking up all the data in a database? Sort of like a long-lived session but you're controlling what data you store so there isn't a huge amount.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With