0

A number of years ago I created my first PHP page from scratch (news site). I'm looking at redoing it and have started redesigning but I am hitting problems with the speed of my page, so a few questions:

  1. What tool can I use to determine where the bottle neck is in the PHP?
  2. All though the page is dynamic it only changes every couple of hours. What would be the best simple tool to use (I do have a VPS but it does have multiple sites on it) that could possibly speed up the process?
j0k
  • 22,600
  • 28
  • 79
  • 90
Trinitrotoluene
  • 1,388
  • 5
  • 20
  • 39

2 Answers2

0

You can use memcache for time-based in-memory stoarage.
Use Explain statement to determine the efficiency of your mysql query.
If there are large number of images on page you can use lazy loading technique and
sprite technology.
Include your javascript files at the end of body tag.
For more information check out this link
http://developer.yahoo.com/performance/rules.html
Thanks

Ja͢ck
  • 170,779
  • 38
  • 263
  • 309
Tarun
  • 3,162
  • 3
  • 29
  • 45
0

The rules i live by are somewhat;

  1. 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.
  2. 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
  3. 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.
  4. Lower the number of images - and everything possible to merge into sheets (often within CSS), do so.
  5. 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

mschr
  • 8,531
  • 3
  • 21
  • 35