A few questions about Javascript and Cookies

A few questions about Javascript and Cookies…

Does having multiple cookies increase http requests or are all cookies sent at the same time for a page?

I am referring to the number of requests sent, not the amount of data/bandwidth, which I know will increase with each cookie. (I am trying to lower the amount of times the server must communicate when a page is requested.)

When JS reads a Cookie, does it cause an HTTP request?

Or is it reading data that is already present on the client-side?

When cookies are sent to the server from a user, is it all at once or individually – in other words are there multiple connections (1 per cookie) or a single connection that sends all cookies at once?

Thanks for clearing any of this up for me and any additional advice.

Cookies are attached via headers to each request, so more cookies is not more requests but each request has the size of the cookies added to it (bigger requests).
JS uses the cookies after it is on the client-side.

Take a look at this article if you want to understand more about how cookies work.

The best way to minimize requests when you are loading a page is to have the least amount of CSS and JS and Image files possible.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.