Posted by Moot on 12/12/06 19:43
Hermann wrote:
> My site is a bit slow showing the main page so I thought caching query
> result in PHP will improve performace.
> Then I read MySQL documentation and saw that MySQL does have a caching
> feature.
> So... now I dont know if doing the PHP caching is worth the pain.
> Would there be any noticed performace improvement if I cache query
> results in PHP, considering that MySQL is already caching the queries?
>
> Thanks
MySQL's caching is a start, but only if the queries are your actual
problem.
Do some profiling to see what portions of the code are causing the
slowdown (can be as simple as echoing out microtime() after each
significant logic block).
If the query turns out to be the problem, then verify that your table
schema has any appropriate indexes and check your query to make sure it
is optimized. Only after you've done this should you worry about
caching.
Finally, if the page does not need to be dynamic (ie: something new
every load), then consider caching the entire page as a static version
of itself for a period of time using Smarty or something similar.
- Moot
[Back to original message]
|