HTML-PHP-MySQL: Query Result Caching inbetween pages
the problem is global but specifically when creating leaches on blogs & forums... when i run a MySQL query it gets back the results and i display them
like
title - promo text - thumnail\images
and with it i provide a link to page to which i will send the id or something which will again query the DB and fetch the results again and then i will display the complete details...
is there ANY
way by which i can
query and get all the results and display only desired attributes and when through a link the user goes to the details page the Query Result\Dataset\PHP (Assoc\Array) Array is just transferred by sent to the other page...
one possibility is send passing as parameters via URL\Form -> GET\PO开发者_Go百科ST other is store it result in session but wouldn't that increase the size of per session
is there a way... plus please tell me you get what i am trying to do
You shouldn't really have to worry about this. But if querying the DB and rendering the page is a performance hit for you (and the data is - mostly - static), then you could start caching either the data or the rendered page itself. Just look into Zend_Cache for an easy, tried-and-tested solution that can handle both of these scenario's.
If you use absolute paths for the images, stylesheets etc it will most probably be cached by browser. Otherwise you can use many of the caching solutions available like memcached
. You can also cache images using phpThumb
and mod_rewrite
as explained here.
I think sessions are your best option in this case:
- they are much more efficient than database queries
- using a $_GET array and the URL will have security issues if the data you are sending around is confidential and even if it isn't, it may diminish your users confidence in you if they see their data being passed around for all to see. You also have to be aware of URL length as Internet Explorer has a limit of 2083 characters (http://support.microsoft.com/kb/208427)
- using $_POST will involve you setting up a (I assume) hidden form on every page a user visits and ensuring that when the user visits a link, the form gets submitted. This just seems like an issue you shouldn't have to deal with.
- You could use cookies but you have issues again with private data being stored client side. Also, if cookies are large, they will need to be sent to the web server every time you visit a new page increasing the amount of bandwidth being used
- you could use javascript to populate an empty div on the same page with the extra data rather than have the user leave the page at all. This won't work if the user has javascript switched off though so you would need to implement some other method as well
精彩评论