Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make localhost faster?

I am currently working on a project and testing it on my localhost.

The thing I am worried about is that pages are loaded quite slow (500-700ms and not less). I thought localhost would load faster than any other web page (as it resides on my local machine). Therefore, if these are the load times on localhost, would they be significantly bigger when moving my site on a remote server?

As technical details, I am developing on CakePHP framework and have several AJAX requests, all taking the above specified time to load. The requests shouldn't be time-consuming, as they load a CakePHP-generated pages with MySQL operations which take less than 3ms (as shown in the framework's debugger). I am also using XAMPP (therefore Apache webserver) on a Windows 7 machine.

Thank you for your answers and I believe this post would be useful to others as well.

like image 230
linkyndy Avatar asked Apr 20 '11 13:04

linkyndy


People also ask

Why does localhost take so long to respond?

The 'taking too long to respond' error indicates that there is a communication problem between the target server and the client (your web browser). It means that the targeted server is taking a long time to send a response to the client. The error is usually sent if the client cannot get a response within 30 seconds.

Is localhost faster?

Directly using the IP address of any interface on the localhost - either the loopback interface (127.0. 0.1) or any other - is the option with the absolutely best performance. The packets will be actually routed through the loopback interface (no matter which IP is actually used) at - practically - CPU speed.

Why my localhost is not working?

It is triggered if the firewall wrongly blocks your server or you're using the wrong port. The localhost error can also happen if your Apache web server or Chrome browser is not configured correctly.


3 Answers

You'll probably see faster loading time - it's unlikely your computer is as powerful as a real server.

Personally, I'm always surprised by how much faster my projects run live - but this could depend on the server. You should upload a quick test to ease your worry.

like image 79
Wesley Murch Avatar answered Oct 15 '22 07:10

Wesley Murch


Also bear in mind that when testing you will probably use debug set to greater than 0. When greater then 0 your model structures are not cached making cake reload them on every request

like image 30
Leo Avatar answered Oct 15 '22 08:10

Leo


If you're saying MySQL is fast, but the slowdown is purely in PHP, enabling the APC extension may help. APC caches the output of the PHP parser and does a few other optimizations. Often it can save a ton.

But in general, you'll want to do profiling. Use XDebug to get profiling information and use WinCacheGrind to read out where things are slow.

like image 31
Evert Avatar answered Oct 15 '22 06:10

Evert