The rules i live by are somewhat;
- If you have a large number of javascripts, merge them into one big one. Puts less stress on server and free's the clients idle requests to deliver imagery etc for actual payload.
- If you have a large number of stylesheets, merge the non-sniff-dependant (media="all" and not 'if lte IE7' etc). Same benifit as above. This technique also lowers overhead for gzipping
- When you have dense mysql queries, producing HTML - stack the .html files in a server-directory. Make use of them, simply by
include 'cache/pageid.html';
or similar. Putting outputbuffers into memory is a vast consumption of ram.
- Lower the number of images - and everything possible to merge into sheets (often within CSS), do so.
- In details, try to create a 'static.mydomain.tld'. This should be a cookie-free domain with one simple http-cache-directive; expires. This could leave you with a pr-request-header in < 120 bytes as opposed to maybe > 1k.
My item 4 really doesnt need much of a tool to achieve that goal.. I simply create a wrapper function which is similar to
function writePageContents($cachefile) {
$maxage = time() - 60*60; // one hour
if($maxage < filemtime($cachefile)) return file_get_contents($cachefile);
else return createPageFromDb();
}
So, make a condensed header, including all of your cacheable scripts and stylesheets, serve them from a 'cdn'. Put all the metas down right - close header and then flush()
.
Then think about if you need to recreate cache - and if not, simply include the local storage from disk