Hi, I've got a site that according to my host is taking up to much CPU and RAM time. The site is running a PHP script and is using MySQL. Is it possible to cache results from queries ran by the script for say a day so rather than fetching the results each time the page loads it's already cached. I normally program in Coldfusion and it's just an extra line added into the sql query on the page and it will cache the results for 24 hours meaning less stress on the CPU and memory. So, is there something similar with PHP? JP
It's hard to say without knowing how your site is setup. There are caching methods, but none are as easy as a single line. How often do the pages typically update? Also what sort of access do you have to the database and the server itself? Also, do a search on google for "php caching" which should turn up some decent results. Also, you can edit my.ini if you have access, and adjust the query_cache_type and query_cache_size (These are only for InnoDB). If you have access to the server itself you can setup squid reverse proxy caching. I assume since you're asking this question, this is not within your control, but I thought I'd throw it out there.
You can use memcached. It is a RAM based caching engine. But you need to run memcached deamon. 1 Caching engine is shared by all the PHP running instances.