4

We are trying to create a new website, and when i write the link of my website on the browser ex: www.mywebsite.com, the waiting time is a bit high.

I have seen some website that has a lower waiting time then mine, is any way to decrease the waiting time , also we are using memcached for the website?

PS: idk exactly how is called, but i see it with firebug, and it says waiting time.

Thank you.

EDITED

This is the codes i have used to get data from database:

function f3($id = '') {
    $id = mysql_real_escape_string ($id);
    $sql = 'SELECT id,post_title,post_content,post_date,post_status,term_taxonomy_id,object_id FROM wp_posts, wp_term_relationships WHERE term_taxonomy_id = 60 AND post_status = "publish" AND wp_term_relationships.object_id = id ORDER BY post_date DESC LIMIT 1 OFFSET 2';
    $res = mysql_query($sql) or die (mysql_error());    

if (mysql_num_rows($res) !=0):
    $row = mysql_fetch_assoc($res); 


    $mycontent = $row['post_content'];
    $mycontent = strip_tags($mycontent);
    $mycontent = substr($mycontent,0,150);
    $mycontent = preg_replace("/\[caption.*\[\/caption\]/", '', $mycontent); 


    $title = AvinD($row['post_title']);

    $old_date = $row['post_date'];              // returns Saturday, January 30 10 02:06:34
    $old_date_timestamp = strtotime($old_date);
    $new_date = date('d.m.Y   H:i', $old_date_timestamp); 


    $first_img = '';
    $my1content = AvinD($row['post_content']);
    $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $my1content, $matches); 
    $first_img = $matches [1] [0];
    if(empty($first_img)){ //Defines a default image
    $first_img = "/img/default.png";
    }

    echo '
        '.$new_date.'

        <a href="single.php?id='.$row['id'].'"> '.$title.' </a> </div>
         <a href="single.php?id='.$row['id'].'"> <img src="timthumb.php?src='.$first_img.'&amp;h=107&amp;w=190amp;zc=1" alt="" />  </a> </div>
        '.$mycontent.'
    '; //echo

    else:
        echo 'Page dont exist';
    endif;
} // end 
Meo
  • 241
  • 5
  • 11
  • Are you loading any external resources? (scripts, css, images, etc) If yes, it's probable that the host of the external resources is acting slow, not exactly your server. – Jorge Guberte Sep 01 '11 at 03:24
  • 2
    For general suggestions, check out [Page Speed](http://code.google.com/speed/page-speed/) and [YSlow](http://developer.yahoo.com/yslow/). – Michael Mior Sep 01 '11 at 03:24
  • 3
    Analogy: some cars speed up to 100kmph for 4 seconds, and some for 10. How could you explain this without knowing which exact the cars are used in the race. – zerkms Sep 01 '11 at 03:25
  • the last comment is nice. I wanted to know witch factor make my website to increase or decrease the waiting time factor – Meo Sep 01 '11 at 03:27

3 Answers3

4

Well a number of different factors can affect your page load time. The three biggest being:

  1. Server Lag
  2. Content Overload
  3. Poor Programming

Without having more details about your website, I'll briefly describe how to diagnose and fix these three big problems. If you provide your website link in a comment on this answer I can be more specific.

Server Lag

This happens when you try to connect to your website, and it hangs for a while connecting. Moreover this can have a blank white page which spins for a while, then finally begins to load your content.

You cannot fix this on your own other than switching hosts, or working with your host to increase your bandwidth and server connection.

Content Overload

The best example of this is when you see someone put tons of images on one page. Keep in mind that every image you add requires the user to download this image before the page is loaded. This includes those in <img> tags as well as background-imagees.

Poor Programming

A symptom of this would be similar to server lag, where you have to wait a while before content begins to load. This can result from a number of things, from a slow Database connection to multiple nested loops. Very difficult to diagnose without looking at the full code.

ShaneC
  • 2,376
  • 4
  • 19
  • 27
  • Hello, can you take a look, www.noa.al/newnoa3/ – Meo Sep 01 '11 at 03:31
  • 2
    Looking at your site it seems like the biggest problem is a slow connection somewhere. It could be your server, or possibly your database. You can mitigate some of the problems by following the suggestions given [here](http://pagespeed.googlelabs.com/#url=http_3A_2F_2Fwww.noa.al_2Fnewnoa3_2F&mobile=false). I would highly recommend, though, contacting your host and complaining about a slow server. There might be something they can do on their end. – ShaneC Sep 01 '11 at 03:37
  • 1
    A suggestion: instead of grabbing the images from `timthumb.php`, perform the resize during the insertion of the article, and then only refer to the image that has already been resized. It might save some time i assume. – Jorge Guberte Sep 01 '11 at 03:37
  • Jorge, as i am not an expert on this, any suggestion how to do this please ? THank you – Meo Sep 01 '11 at 03:39
  • 1
    @Meo I'm not very familiar with the Wordpress architecture, but my guess is that you'll have to create a plugin that uses a hook and a filter. For example: when you upload the image (that's the filter), the hook triggers the resizing of the image. This link will give you a better idea about the existent filters: http://codex.wordpress.org/Plugin_API/Filter_Reference#Database_Writes – Jorge Guberte Sep 01 '11 at 03:47
  • i havent implemented the cache yet. what about the coding ? any help ? can i paste the functions i have used to get the date ? can some one help if i am doing this wrong or not. Thank you – Meo Sep 01 '11 at 03:50
1

A lot of it depends on what your site does. I recommend starting by profiling. It will help you pinpoint your effort for maximum gain.

You are also the right track with the Firebug Net tab, check out Yslow as well.

In general:

  • Check server CPU usage, network latency (ping) etc. Resolve any issues.
  • Get more RAM and/or use it more effectively. Most of the items below follow from this.
  • Cache expensive operations
  • Increase speed of the database
    • Reduce the number of queries performed per page
    • Split database to another server(s) to reduce contention
  • Use a reverse proxy/cache to divide requests to several front-end web servers.
  • Split application server to its own server(s).
  • Optimize page assets for quick delivery
    • Combine CSS and JS files into one file each.
    • Minify them - remove extraneous characters
  • Use Gzip compression on all text files served.
  • Use CDN's to offload assets to other domains, improves parallel performance drastically on modern browsers.
    • Images should be served from another domain.
    • If possible CSS/JS also.

These are well detailed at:

Community
  • 1
  • 1
Gringo Suave
  • 29,931
  • 6
  • 88
  • 75
0

solutions: For Slow script: use firebug & YSlow Plugin for firefox to detect what slows you down. For Slow Server: use cloudflare to speed up your server, up too 60% or change your hosting compney.

Towhid
  • 618
  • 2
  • 5
  • 19