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 performance-wise) in using local
storage to replace cookie functionality except for the obvious compatibility
issues?
Thursday 23 November 2017
html - Local Storage vs Cookies
Answer
Cookies and local storage serve different
purposes. Cookies are primarily for reading server-side,
local storage can only be read by the client-side. So the
question is, in your app, who needs this data — the client or the
server?
If it's your client (your
JavaScript), then by all means switch. You're wasting bandwidth by sending all the data
in each HTTP header.
If it's your server, local
storage isn't so useful because you'd have to forward the data along somehow (with Ajax
or hidden form fields or something). This might be okay if the server only needs a small
subset of the total data for each
request.
You'll want to
leave your session cookie as a cookie either way
though.
As per the
technical difference, and also my
understanding:
Apart
from being an old way of saving data, Cookies give you a limit of
4096 bytes (4095, actually) — it's per cookie. Local
Storage is as big as 5MB per domain — href="https://stackoverflow.com/questions/2989284/max-size-of-localstorage-values">SO
Question also mentions
it.localStorage
is an implementation of theStorage
Interface. It stores data
with no expiration date, and gets cleared
only through JavaScript, or clearing the Browser Cache /
Locally Stored Data — unlike cookie
expiry.
php - file_get_contents shows unexpected output while reading a file
I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...
-
I have an app which needs a login and a registration with SQLite. I have the database and a user can login and register. But i would like th...
-
I would like to use enhanced REP MOVSB (ERMSB) to get a high bandwidth for a custom memcpy . ERMSB was introduced with the Ivy Bridge micro...
-
According to my understanding, and my calculator, cos(90 degrees) equals 0 . In my code, I have a funct...
No comments:
Post a Comment