I am a fresher to web development.
In my application I need to have caching so any one can explain me how to do caching of PHP pages in detail?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Caching in PHP can be mean storing the results of a particular function last time it was called in case that function is called multiples times in the same script (with the same parameters).
However I think the main and more powerful meaning is storing the complete output of a dynamically generated page, and serving this up when the page is requested again instead of actually running the full PHP script to regenerate that content.
For pages I want to cache, I have an AJAX command that writes the content into a database after the page is generated. It also adds an expiry time – say time() + 20 (expire in 20 seconds).
Then I add a condition at the top of the page to check for an unexpired cache for the page in the database. If found it returns that, otherwise it continues to re-generate the full page.
This article helped me get started:
http://simas.posterous.com/php-data-caching-techniques