Question about the number and size of cookies _ javascript tips-js tutorial

Source: Internet
Author: User
During an interview, the interviewer asked me a series of questions about browser cookies, including cookie size, cookie count restrictions, and how to operate cookies. To be honest, I seldom pay attention to this issue and use cookies during the usual JS usage process. So this time I was stunned and couldn't say anything, finally, I can only honestly tell you that I am not very familiar with the operations on this cookie. Today, some colleagues asked questions about cookies. I went to the Internet and made some summary records for use from time to time. Cookie operations should be relatively familiar to JS programmers, so they will not be explained too much.

The following are the different cookie restrictions on different browsers:

IE6.0

IE7.0/8.0

Opera

FF

Safari

Chrome

Cookie count:

Each domain has 20

50 for each domain

Each domain has 30

50 for each domain

No quantity limit

Each domain has 53

Total cookie size:

4095 bytes

4095 bytes

4096 bytes

4097 bytes

4097 bytes

4097 bytes

After the number limit is exceeded:

1. The processing of IE and Opera is the same. They all use the "least recently used algorithm". When the cookie has reached the limit, the oldest cookie will be automatically removed to leave available space for the newest cookie.

2. FF is very special. Although the last cookie is retained, it seems that there is no rule to delete the existing cookie randomly.

Note:

When we perform page cookie operations, we should try to ensure the number of cookies and the corresponding size. Best cookie count <20 ~ 30; the best cookie size <4 K

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.