0

I have a site, which requests data from a SQL DB, from different rows, in different tables on each pageview.

I'm planning to just save all the data as temporary cache in cookies (with JSON) on the first pageview, so things work out allot faster (no more querying).

Haven't completely thought it out yet, but I'm just planning on throwing it all in an array, JSON decoding it, throwing it in a cookie and then pulling it back up when needed.

What concerns me is the possibility of issues that could encounter, when storing large cookies on the client side.

Do you guys think this is a good idea, or a stupid one?

If its stupid, any alternatives?

  • Cookies have a size limit, you should take care of that. See also [chrome cookie size limit](http://stackoverflow.com/questions/2543851/chrome-cookie-size-limit) for alternatives. – hakre Feb 23 '12 at 13:23
  • your data is too large for cookies! Cache the data server-side in files – aletzo Feb 23 '12 at 13:24
  • I do this for menus and result that dont change much, but not for large amounts of data and i store it in a `$_SESSION` var not client side... – Lawrence Cherone Feb 23 '12 at 13:24

1 Answers1

0

consider using APC or Memcachced

These are capable of storing large data and are faster to access.

Using Cookies has several drawbacks other than its size limit. On every page request, the cookies are send back to server, thus, increasing your tranfer data/traffic, and request becomes heavier. The reason why a CDN concept came to picture, to prevent cookies transfers.

linuxeasy
  • 6,269
  • 7
  • 33
  • 40