First GET request too slow (wordpress) - wordpress

I am running a VPS with multiple wordpress installations on it. When I access my website, the first request that the browser performs is a GET request that takes about 10 seconds to complete, then the css, js files and so on start to be downloaded as fast as one could expect. That slows down my website a lot.
I am running apache2 and php5 with default configurations, plus the following plugins in use:
Wordpress ZenCache.
php's APC cache.
mod_deflate.
The websites are just landing pages with minimal templates, nothing huge. When pages are cached, the previous time can be improved up to 2 or 3 seconds as much.
I understand that many wrong things could make this happen, but could anyone expert devise a possible starting point to fix?
By the way, I had to set up some aliases and redirections with mod_alias and mod_rewrite, I would like to know if that may cause this behaviuor as well.

After following Andrew's advice, I disabled the default reverse DNS lookups in my virtual hosts configuration file by adding the option
HostnameLookups off
In addition, I disabled the use of symlinks when possible with
<Directory /> Options -FollowSymLinks </Directory>
And disabled the logs as well. Now the problem has been solved and everything works much faster now. It was not directly related to Wordpress since a simple html landing page was also suffering from this latency.

Related

htaccess VS safe redirect manager

I'm updating a WP theme, changing permalinks, and also migrating to https at same time. Have 1 wildcard redirect (removing categories from URL) and about 140 manual redirects (old joomla links). Need advice between going with htaccess or Safe Redirect Manager. My only concern is page load speed, not extensible features or tracking.
It would seem like htaccess would always be the fastest but my htaccess file is 20kb (because of all the manual redirects). And so I wonder if loading a php plugin on every request (however all redirects intelligently cached) is faster. SRM might seem like the better option considering all the manual redirects but I'm wondering if there are some old-school htaccess phreaks who might say otherwise. I don't want to go through the hassle of testing.
The best solution would probably be to put your redirects in the main Apache config. Then this is only processed once when the server is started, rather than a 20kb htaccess being parsed for every request. As for your other option, not sure on the performance impact.

Force Drupal to merge and compress css

I'm working on a Drupal site. When I test in IE8 and IE9 the css don't load on my local server. When the site is deployed everything is fine. I need to be able to test on my local server to fix any issue I might encounter before pushing the site live.
I guess it is because this site is over IE's limit in http requests. Is there a way to force Drupal to optimise the css even in development mode.
When I go to the admin/performance menu, I can't select the optimise css option.
Did you "borrow" this htaccess from another site? Reason I ask is because you said you are not using this htaccess for neither vehicletrackingprices.co.uk or quotes.expertsinmoney.com but strangely enough you have a 301 re-direct for quotes.expertsinmoney.com and an index request for vehicletrackingprices.co.uk. :/
Could they be the cause of your problem? If we're lucky, they are. Am I sure? No. But either way those two items deserve atttention.
On the other hand, I tested your htaccess against your 301 so that I can see if it has a ny errors your server may be fighting with and I did find the following:

Can anybody help explain whats causing my site to load so badly?

I have just launched the website - exactabacussoftware.com built with a custom theme in wordpress.
I noticed that the page load time was stupidly slow and when I checked the results with pingdom I could see that a lot of the analysis was duplicated and I'm not sure why this is or even if it is whats causing the site to load so slowly.
I haven't yet integrated a cache plugin which I intend to do but regardless of this I cannot see why this page loads for around 24 secs.
The entire site loads properly except for the blog page -
http://tools.pingdom.com/fpt/#!/cEmMjD/http://www.exactabacussoftware.com/blog
Server Spec:
Windows server 2008R2
IIS version 7.5
PHP version 5.3.19
Anyone got any ideas as to why this page is loading so slow?
here is the test sites result aswell for comparison -
http://tools.pingdom.com/fpt/#!/bw4JTo/wp-eas.exact3ex.co.uk
The only code changes have been the rewrites to the URL's
Over to you guys...
I think the issue is with a custom theme.
Try doing this steps:
Remove all active widgets
Uninstall all plugins
Check loading time - if not improved it's an issue with custom theme.
One more thing to do (to check if it's not the host issues) - activate default wordpress theme and check average loading speed, if speed is not improved try to configure your server correctly or change hosting plan or hosting provider.
Wait 21.07s (The web browser is waiting for data from the server).
The most common reason for this in the case of Apache is the usage of DNS Reversal Lookup. What this means is that the server tries to figure out what the name of your machine is, each time you make a request. This can take several seconds, and that explains why you have a long WAIT time and then a very quick load, because the matter is not about bandwidth.
The obvious solution for this is to disable hostnamelookup in /etc/httpd/conf/httpd.conf
HostnameLookups Off

WP Admin extremely slow

The WP back end of a site I'm working on (It's a multisite) takes about 25 seconds to load.
Everything was working fine until yesterday and the front end still works perfectly well. All other sites on the same server run just as well, so it MUST be a WP back end issue.
I don't remember exactly what change it was that made it so slow. I remember updating WP recently (to version 3.4.2), adding some plugins on one of the sites and changing the max upload file size.
I tried to disable all the plugins, changing the themes back to default, changing the max file size back, and adding define('WP_MEMORY_LIMIT', '1024M'); (and other values) to WP-config but none of it helped.
Also tried to 'Update network', but I got an error - couldn't connect to host.
Any ideas?
I got in touch with our network admin and we resolved the issue.
I will copy his answer here. Hope it helps someone.
Does Wordpress use 'self-referential URLs' ? What I mean by this is...
is wordpress trying to access it's own templates/css using fully
qualified domain names in the URL (e.g. http://example.co.uk/someurl )
Because we use Network Address Translation (NAT) on our firewalls to
hide the real IP address of the server, it has the side effect that if
the server tries to access it's own URLs, it will try to send the
traffic to the external interface on our firewall, which is where the
DNS resolves to.
The fix for this is very simple - we just add the site url into the
/etc/hosts file so that the server knows to use it's own IP address
instead of the address on the firewall.
So he added our address to the hosts file and now it works perfectly.
Awesome.
I've seen this before where the admin pages are trying to poll external Wordpress sites for details of Wordpress upgrades, plugin updates and Wordpress news. If there's no proper access (because of firewall restrictions, bad DNS, etc) then the page has to wait for the HTTP requests (I think WP uses cURL) to timeout.
If you're still unable to identify the cause I'd recommend a catch-all solution of installing xdebug and profiling the page with webgrind, xcachegrind, etc
Had the same problem for a week and now the problem of very slow WP-admin was solved!
Before, I cannot access my sites if I use incognito or I am not logged in as WP user, but all times in the wp-admin, it takes me 40 seconds- minute or even never.
Solution that worked:
I accessed the files in the file manager using the CPanel, and I saw so many unused and unnecessary folders and themes and that's the reason that causes the very slow access to admin.
It was because during the days of being a newbie, I stuffed a lot of files in the Public Http and that made it congested.
I logged in to another CPanel account that I bought personally before, and compared the folders of the "proper" versus the "congested" and compress, backed-up and deleted all the unnecessary.
My host: Hostgator, responded well also.
Hope this would help others.
I also had a very slow Dashboad in wordpress. Reading the James C´s answer, I realized that my site is located in a corporate intranet behind a firewall to access internet.
James C answered:
"I've seen this before where the admin pages are trying to poll external Wordpress sites for details of Wordpress upgrades, plugin updates and Wordpress news. If there's no proper access (because of firewall restrictions, bad DNS, etc) then the page has to wait for the HTTP requests (I think WP uses cURL) to timeout."
My solution was avoid all the internet conections: (1) disable all the wordpress updates using the wordpress plugin "Disable all wordpress updates". (2) activate de wordpress pluging "Disable google fonts"
After these two plugin activations, the Dashboard works to a suitable speed.

PHP Code stuck in Cache [Memcached] (WordPress)

Been having a bit of a problem with my site regarding our caching method and my php code not refreshing or flushing.
To start, my site is a WordPress site on a dedicated Nginx webserver. I used W3 Total Cache for the initial caching setup. Everything was set up to cache through Memcached.
(I should note, my website is somewhat of a 'guest' on this server, which is bit of a semi-community donation semi-sponsored server that runs some other things. The admins are skilled but also volunteers. I have their full support for fixing things, but they don't have time to troubleshoot my very odd issue (especially because I asked for caching to get turned on for the site myself). If we had some hints on what to go on it would make things easier for us than taking shots in the dark ;) So any suggestions are welcomed.)
At some point we noticed that changes to php pages and Wordpress & Plugin updates were not working at all, while the code on the server reflected updates, the pages still processed through the older php code.
This presented a couple unique issues. W3 Total Cache stores it settings in php files. Other php files, when deleted, stop working, but when they are restored to the server, memcached still insists on using its ultra-old memcached copy. The W3 Total Cache settings, whether i removed or altered the settings php files, would NOT stop running everything through cached memcached data.
The server admin attempt rebooting memcached and then flushing it. Neither of those seemed to have any effect. All the other basic settings seem to be set-up correctly.
We can, of course, still add new plugins, all the data that comes from the database works just fine.
At least one other site on the server that is not wordpress also uses memcached with no issues.
Any help is appreciated, should be able to provide further information if it is needed.
Do you have apc.stat = 0 in your settings? Does restarting php engine help?
This is going to sound really obvious but you didn't mention it so:
Did you try turning off the Total Cache plugin entirely to confirm you can see the changes when caching is disabled?
Until you've done that and made sure you get the results you expect, there's no way to know that memcached is really the problem.

Resources