Local Storage vs Cookies

后端 未结 7 1467
名媛妹妹
名媛妹妹 2020-11-21 11:04

I want to reduce load times on my websites by moving all cookies into local storage since they seem to have the same functionality. Are there any pros/cons (especially perfo

7条回答
  •  清酒与你
    2020-11-21 11:51

    Cookies:

    1. Introduced prior to HTML5.
    2. Has expiration date.
    3. Cleard by JS or by Clear Browsing Data of browser or after expiration date.
    4. Will sent to the server per each request.
    5. The capacity is 4KB.
    6. Only strings are able to store in cookies.
    7. There are two types of cookies: persistent and session.

    Local Storage:

    1. Introduced with HTML5.
    2. Does not has expiration date.
    3. Cleard by JS or by Clear Browsing Data of the browser.
    4. You can select when the data must be sent to the server.
    5. The capacity is 5MB.
    6. Data is stored indefinitely, and must be a string.
    7. Only have one type.

提交回复
热议问题