I'm working on a site and I have a performance related question.
I have a page that queries the DB 16 times to get information for the page ending up with 20 different arrays.
I was thinking of storing this information in cookies where I would serialize the array and then store it in a cookie.
I'm wondering if it would give better performance to store it in a session.
My orginal idea to do cookies was to minimize the memory usage on my server and to create more persistance for the user.
Here's my thinking:
storing cookies might double the transmission time because:
- their computer has to receive request
- my computer processes it and
- my computer sends request to get cookie data.
-their computer sends data
-my computer receives and completes processing
-final page is sent to the user
however with a session variable only the following has to happen.
- their computer has to receive request
- my computer processes it, gets session variables and completes processing
-final page is sent to the user
It does seem that session variable would require more system resources than cookies but I'm not sure how much of a difference this makes as the page is less than 15k.
I do however believe that using sessions or cookies would make a dramatic difference over querying the DB for each page view, am I correct here?
Just trying to get a better understanding.
Thanks,
Bryan