Recently I’ve been developing some JS stuff using Cookie Jar (source). Everything went great and Cookie Jar got along even with IE :) However, cookie jar cookie happened to grow and grow to fast.
Cookie Jar stores parts of Cookie as a key-value pair [key][value], so if you have a lot of small stuff – the cookie will be two times bigger than the data stored in it. Example:
[m] – number of chars: 2 (m,5); total amount: 6 ; waste 4 chars.
Phi, nothing special you say. Only 4 characters. In such a simple example maybe but if you store a lot of stuff, waste will be much bigger.
There has been additional problem. Some characters where stored as HTML entities. I don’t know why – I’ve stored in cookie jar only numbers ;)
So, my cookie grew and grew more rapidly. And along with this – something else happened. Performance started to be really bad. Everything worked really slow. Can’t say whether or not it is only Cookie Jar fault, but after switching to my own cookie engine, performance got better.
When I’ve been using Cookie Jar – “setting up” GUI took some time, so users felt this delay. Currently all init stuff goes really fast and none of them feels this.
Whether or not use Cookie Jar?
Cookie jar is convenient and easy to use. If you don’t store whole bunch of small stuff in it and you don’t care so much about performance – definitely you should use it. However if you need something really fast and thin – you should write your own dedicated cookie handler.