views:

33

answers:

1

Regarding web optimization, load-time, speed performance and assuming data size to be equal:

Is it faster to have more cookies but smaller, or less cookies but bigger?

For the technically inclined: would it be more efficient to concat values separated by a known delimiter resulting in a larger cookie size, or to have smaller cookies containing single values?

And for the sake of argument, let's assume we're not in danger of exceeding the 4k/20 cookie limit =)

Thanks!


Edit: This thread didn't come up in my searches, but apparently it asks the same question so I apologize for the repost:

http://stackoverflow.com/questions/1105951/in-a-website-setting-one-cookie-is-better-than-setting-many-single-cookies

IMHO, the answers seem vague and even contradict, so maybe there is no clearcut answer here. It would be nice to have some empirical benchmark data or technical basis for an answer, but that might be too much to ask =)

+2  A: 

Each cookie has additional attributes, like expiration date. If you don't have to change a cookie each time, I'ld go for one cookie containing all data.

Lekensteyn
Yes, assuming all else being equal (including expiration date) I'm interested in which option would yield faster page loads.
Qyx
That will be one cookie then. Firefox stores everything in SQLite databases (and I believe Chrome does the same). Every row is one cookie, with attributes like name, value, expiration date and more. If you've only one cookie, you don't have to worry about scripts/users accidently changing a single value (example: domain of a session ID is set to `.example.com`, with new cookies using `www.example.com`. `.example.com` always overrides `www.example.com`).
Lekensteyn
Thank you for your answer! And although you're correct in that there would be less to worry about with one cookie (like the accidental script/user changes you mentioned), my interest lies more with speed optimization and page load time =) Thanks!
Qyx