
This one’s a no-brainer. It is obvious that every time you run a php script, the interpreter has to compile it, then spit out the html output and deliver it to the requester. If you cache the html files and serve them directly, without recompiling them every time a visitor requests them, you`ll improve the speed of your website - a lot.
You can build your own, custom caching system and/or use memcached. Good luck!
If you would like to make a comment, please fill out the form below.
Caching the output of a PHP script won’t stop the script from being compiled every time it’s requested. It will only stop it from being executed.
To cache the compiled version of a PHP script, you need an accelerator like eAccelerator, APC or Zend. Some of these products do other things as well like optimisation.
Caching the output of your script will usually make your script much faster but this method has drawbacks such as having stale pages. Even if you delete your cache every fifteen minutes, visitors may still see a page that is fourteen minutes old.
Well, it depends on the type of site how often you clean the cache and serve the fresh page to the user. If you have a news site, which, lets say, aggregates news from several sources, then you should refresh your cache at least once a minute.
For a blog, a longer period of time should suffice. Caching is good for blogs - as far as I know, Wordpress compiles a page every time it is requested, even if it hasn’t been updated. That’s why a caching plugin comes in handy.
Also, page caching is good in case of a digg-attack, to reduce server load and avoid being kicked out of your hosting account for utilising too many resources :D