Hello,
This is seriously baking my noodle. And I am getting worried as launch date is in 6 days.
You can see how much it hang from my network screenshot below...
[[LINK href="http://i.imgur.com/nnrPz.jpg"]]http://i.imgur.com/nnrPz.jpg[[/LINK]]
Pretty bad isn't it - and I know 100% it is my theme and not the database/server - because if it begins to start going slow, I immediately switch to the 'twentyeleven' and it's super fast.
The admin control panel is super fast and fine.
<strong>Things I've tried...</strong>
1. De-activated all plugins - no change..
2. Deleted entire functions.php - no change..
3. Deleted all javascript from theme - no change...
4. Migrated it to new location, new data base, and started a fresh database (no mysql dump, I manually added content again) - no change...
5. Tried all these together - no change...
But as soon as I switch to the 'twentyeleven' theme it's fine - it speeds up.
----------------
Also I cannot for the life of me get the search.php to work? So I'm gesssing something is seriously wrong.
And suggestions please would be great and if a fix is found I will award winnings to them.
The problem is that it is so sporadic, it's hard to pin point the problem. Because one minute it is fine, the next it is slooooow.
I know it is vague but if people want to PM me I will share the link, but please keep this site link safe from public as it is not launched yet.
Ideas on the search.php not working would be great too - and I award prize money to them too, but maybe the problem could be linked.
Thanks
Josh
Dbranes answers:
I would recommend the debug plugins, there you can get various debug-information:
fx
http://wordpress.org/extend/plugins/debug-bar/
http://wordpress.org/extend/plugins/blackbox-debug-bar/
(they can profile your pages, and for example list all the slow queries you might have)
Dbranes comments:
I have seen similar problems with sites that are fetching data from remote sites on each reload
(fx. using file_get_contents("http://example.com") in the theme )
You can also manually profile your code using [[LINK href="http://php.net/manual/en/function.microtime.php"]]microtime()[[/LINK]] function in your theme files.
Some prefer to use more advanced profiling, like [[LINK href="http://www.xdebug.org/docs/profiler"]]xdebug[[/LINK]] or [[LINK href="http://newrelic.com/"]]new relic[[/LINK]].
Dbranes comments:
ps: here is also a nice Wordpress timer function:
http://codex.wordpress.org/Function_Reference/timer_stop
Josh Cranwell comments:
You may have possible solved my issue from using the blackbox.
Possibly - I am going to hold open the question until the expiry time, while I continue to test.
I noticed in the SQL querie times, all my querys wer mili secs (1ms to 2ms) and then it became apparent that one in the list was taking 22 secs...
It was this... [[LINK href="https://gist.github.com/3341243"]]https://gist.github.com/3341243[[/LINK]]
Does look rough to you?
Thanks
Dbranes comments:
ok, that's great.
Next step is to try to comment out the $exhibitorMeta
query and the corresponding if-loop
if ($exhibitorMeta->have_posts()))
to see if the page will run fast again, if so, then the next step is to investigate the $exhibitorMeta
query or try to replace it, or skip it if possible.
Dbranes comments:
you can also reduce the number of get_post_meta
calls,
you are calling it twice, you could reduce it by using fx:
$facebook_page=get_post_meta($post->ID, 'Facebook Page', true);
<?php if (strlen($facebook_page)>0) echo '
<li><a class="exhibitor-meta-icon-facebook" href="' . $facebook_page . '" target="_blank">View our Facebook Page</a></li>
'; ?>
instead of
<?php if ( get_post_meta($post->ID, 'Facebook Page', true) ) echo '
<li><a class="exhibitor-meta-icon-facebook" href="' . get_post_meta($post->ID, 'Facebook Page', true) . '" target="_blank">View our Facebook Page</a></li>
'; ?>
Dbranes comments:
you can also reduce the number of get_post_meta
calls,
you are calling it twice, you could reduce it by using fx:
$facebook_page=get_post_meta($post->ID, 'Facebook Page', true);
<?php if (strlen($facebook_page)>0) echo '
<li><a class="exhibitor-meta-icon-facebook" href="' . $facebook_page . '" target="_blank">View our Facebook Page</a></li>
'; ?>
instead of
<?php if ( get_post_meta($post->ID, 'Facebook Page', true) ) echo '
<li><a class="exhibitor-meta-icon-facebook" href="' . get_post_meta($post->ID, 'Facebook Page', true) . '" target="_blank">View our Facebook Page</a></li>
'; ?>
Dbranes comments:
aha, or this is probably better, since these are boolean:
$bFacebookPage=get_post_meta($post->ID, 'Facebook Page', true);
$bTwitterUse=get_post_meta($post->ID, 'Twitter User', true);
...
<?php if ( $bFacebookPage || $bTwitterUser', true) || ...){?>
and so on.
Dbranes comments:
replace the above with:
<?php if ( $bFacebookPage || $bTwitterUser || ...){?>
Dbranes comments:
here is a pastebin rewrite to reduce the get_post_meta
calls
[[LINK href="http://pastebin.com/347FmmVk"]]http://pastebin.com/347FmmVk[[/LINK]]
ps: sorry for the code mess above ;-)
Josh Cranwell comments:
If I'm honest I don't actually need it - runs a lot healthier with out it so I'm happy for now.
Site loads instantaneous compared to previous - but as it was so sporadic I will keep the question open till last min incase slowness returns.
Thanks
Dbranes comments:
ok let's see what happens ;-)
cheers
Daniel Yoen answers:
try to activate debug mode
in config.php
define('WP_DEBUG', true);
Daniel Yoen comments:
Could you tell me your website address ?
Josh Cranwell comments:
I had been trying this but nothing was apparent - I used the blackbox plugin which enabled me to possibly see the problem - but I am going to be testing over the next few days
Daniel Yoen comments:
did you use plugin for contact form ?. Your script may conflict
Josh Cranwell comments:
Yeh I do... But even when deactivated it was still slow.
This was causing like between 10-20 secs in SQL time - buggy so I've removed it and it seems to be so much more responsive.
https://gist.github.com/3341243
Abdelhadi Touil answers:
Hello.
You schould activate debug mode to see what hapening, and it's better to test other themes (not just 'twentyeleven'). you can test several free ones.
Then I think it's necessary to have the website link, and also to be able to have a look at your theme files.
Good luck.