Apache slow time to first byte TTFB linked to slow DNS lookup [localhost]

A really brief post here

I had an issue where I had a virtual domain (say jaspreetchahal.org) configured with apache virtual hosts and in my hosts file entries on my iMac (sudo vi /etc/hosts), I want this domain to resolve to

The problem I had was that sometimes it was taking up to 10 seconds for something to show up,  I checked pretty much all my configurations, I didn’t see any issue with those.

Then I diverted my attention to the hosts file itself just to found out that I had over 20 test domain records resolving to

What I did then resolved the issue for me

I consolidated all my domains to a single line as shown below

and removed all the unwanted records from the hosts file

Tada! that’s how fast it should be on a localhost. 🙂

This is what solved for me, I am not saying that it will for you too, there could be several other reasons associated with this issue. There are far too many things that could contribute to the slowness, if you solved it in any other way, feel free to share.

I hope this helps.

WordPress Fatal error: Allowed memory size of {N} bytes exhausted (tried to allocate {N} bytes)

The default allocated memory to any Wordpress site can vary on your settings either at the system level (PHP Configurations) or how you set it up in WordPress. When you get this kind of error ( Allowed memory exhausted), that means that your … [Continue reading]

Braintree\Exception\SSLCertificate with braintree_php sdk

Ok so I scratched my head around this for a while to figure out why would this happen There are several reasons The request URL was malformed. (This was ok in my case, I've logged each request and didn't see any issues) The request was an … [Continue reading]

NodeJS How to determine or check for current OS (Operating System)

There are two ways of doing it, First using the native OS module, Check out the API function available for OS module here https://nodejs.org/dist/latest-v5.x/docs/api/os.html#os_os_platform  Basically, all you have to do is to call platform() … [Continue reading]

PHP check if search engine bot

How do you check if your website is being crawled by a bot or spider, or in case you want to expose a certain section or sections of your website to the search engines which otherwise would be hidden from them as they are protected … [Continue reading]

Ionic 2+ How to access parent navController

There could potentially be scenarios when you will have something like this [crayon-5dcc701002ffa082563347/] Each of ion-nav components have their own NavController, when you try to push or pop a view, depending on the inheritance level of your … [Continue reading]

PHP: Check if Start of each word in a sentence is uppercase or any part of a word is UPPERCASE

When working with strings, occasionally we would want to check if any part of a word is uppercase or start of a word is an uppercase letter. This post provide a generic function that can be extended to match your needs. For this post I will use … [Continue reading]

How to convert a string to equivalent integer value based on ASCII codes in Javascript

Hi Guys, Here is a quick tip if you would like to convert a string into a sum of ASCII codes for all characters Function you can use For ES5: [crayon-5dcc701003759098755185/] We can do equivalent in ES6 … [Continue reading]

Hunspell with PHP on Windows – Part 1

Ok so I hear you saying, how the hell can I use Hunspell and PHP with Windows, Now the way I am going to show you isn't the only way but is a much simpler way without compiling and using binaries. What is Hunspell? Well I can re-write what's … [Continue reading]

PHP Start of the day and End of the day for a timezone Util functions

This is a quick post where I am sharing a couple of functions to calculate start of a given day and end of the day for a given timezone Start of the day [crayon-5dcc701003f7f343730090/] End of the … [Continue reading]