DNS server used by my shared hosting is slow. Any way too add entries like in windows' hosts file?

StackOverflow https://stackoverflow.com/questions/23200549

Pergunta

I'm not that experienced with servers, so i'm sorry if this is a noob question.

Basically i have a PHP script that connects to IMAP mail servers like this

imap_open('{imap-mail.outlook.com:993/imap/ssl}INBOX', "example@example.com", "password");

That code was slow at first on my localhost (WAMP) and on my shared host (30+ seconds), while it was really fast on my VPS hosting (~1 second).

I noticed that it was because of the domain name resolution was slow so i added the IP address of imap-mail.outlook.com to my hosts file in Windows.

And then it started working fast like it should be, in ~1s on my localhost as well.

But how can i fix it on my shared hosting? Is there some equivalent in cpanel to windows hosts file? Or will i have to contact my host support?

Foi útil?

Solução

Unfortunately in shared hosting, you are not likely to have access to /etc/hosts file to specify your own DNS resolution overrides. Just refer to the resource using it's IP address and you should not have any need to do DNS resolution at all.

If the resource changes IP address, then you could potentially create a separate process to determine DNS resolution for the resource and cache the IP locally, then again use that IP address in your imap_open() call.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top