cohorts icon indicating copy to clipboard operation
cohorts copied to clipboard

Limits regarding cookie sizes

Open abourget opened this issue 11 years ago • 1 comments

Thanks for the code! Wondering if there is a limit to the number of experiments we can run, since we're using cookies ? Also, aren't cookies sent to the server all the time, wasting bandwidth ?

abourget avatar Sep 11 '14 14:09 abourget

I know it's a bit old, but hope it can still help:

  • You'd need quite a lot of experiments to hit the limit, but in theory you could. According to this source: "To be compatible with the most browsers, you should create no more than 30 cookies per domain and all 30 cookies should take up no more than 4KB of space (4096 bytes).". More detailed info can be found here
  • Yes, those cookies will be sent with every request to the server, which would increase bandwidth usage / latency. On the other hand, you might be able to use the data in those cookies server-side if you wish.

localStorage might be a better alternative in some cases, because it won't send the data with each request, and it's generally more "generous" in terms of storage. Please note that localStorage has its tradeoffs compared to cookies. It's not always better. One limitation of localStorage is that it's not as widely supported (but it becomes much more broad). localStorage does not have auto-expiry mechanism, as cookies do. Also, localStorage cannot cross domains, whereas cookies can be set to do so, and this can be desired in some cases.

Perhaps a shameless plug, but if you're worried about those things, or if you wish to have greater flexibility, I would recommend looking at AlephBet - an open-source A/B testing framework inspired by Cohorts. AlephBet supports those two features that cohorts currently doesn't:

  • localStorage. This is the default adapter.
  • You can create your own custom adapter. For example, you could use cookies with specific expiry, or any other method.

gingerlime avatar Jul 04 '15 16:07 gingerlime