# Does nginx have resolve cache?

**URL:** <https://www.ruby-forum.com/t/does-nginx-have-resolve-cache/214513>\
**Category:** NGINX\
**Created:** [December 4, 2011, 9:14am UTC](https://www.ruby-forum.com/t/does-nginx-have-resolve-cache/214513 "2011-12-04T09:14:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [December 4, 2011, 9:14am UTC](https://www.ruby-forum.com/t/does-nginx-have-resolve-cache/214513/1 "2011-12-04T09:14:43Z")

</div>

Hi

I have seen sometimes that google dns has banned my servers. Since I use  
proxy hostnames instead of ips, does the nginx cache the response from  
dns servers or queries them everytime it receives a request?

Regards

Posted at Nginx Forum:

> **[Does nginx have resolve cache?](https://forum.nginx.org/read.php?2,219569,219569#msg-219569)**
>
> Hi I have seen sometimes that google dns has banned my servers. Since I use proxy hostnames instead of ips, does the nginx cache the response from dns servers or queries them everytime it receives a request? Regards

---

<div class="post-metadata">

**Author:** ![mojiz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a87d85/32.png) [@mojiz](https://www.ruby-forum.com/u/mojiz)\
**Post date:** [December 4, 2011, 4:56pm UTC](https://www.ruby-forum.com/t/does-nginx-have-resolve-cache/214513/2 "2011-12-04T16:56:04Z")

</div>

On Dec 4, 2011, at 12:13 PM, mojiz wrote:

> Hi
> 
> I have seen sometimes that google dns has banned my servers. Since I use  
> proxy hostnames instead of ips, does the nginx cache the response from  
> dns servers or queries them everytime it receives a request?

Check this 🙂

> **[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#resolver)**
>
> This directive appeared in version 1.11.8.

Basically - yes, and there are more configuration parameters now to use  
to tune it more nicely.

---

<div class="post-metadata">

**Author:** ![mojiz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a87d85/32.png) [@mojiz](https://www.ruby-forum.com/u/mojiz)\
**Post date:** [December 15, 2011, 11:19pm UTC](https://www.ruby-forum.com/t/does-nginx-have-resolve-cache/214513/3 "2011-12-15T23:19:33Z")

</div>

I saw the announcement but it looks like Nginx 1.1.11 isn’t still  
honoring the DNS ttl or the “valid” parameter at all.

I have 2 related questions to this topic

1. Is the following configuration correct to get the resolver  
“resolving” at least every 5 secs?

location /mylocation {  
resolver 127.0.0.4 valid=5s;  
set $myserver “myserver:1000”;  
proxy\_pass http://$myserver;  
proxy\_redirect [http://myserver.mydomain.in:8000](http://myserver.mydomain.in:8000)  
[https://www.myserver.com](https://www.myserver.com);  
}

1. If I receive 100 request in 50 seconds and have my DNS (127.0.0.4)  
returning records with TTL=1. How many request to my DNS should Nginx  
perform in that period?

Posted at Nginx Forum:

> **[Re: Does nginx have resolve cache?](https://forum.nginx.org/read.php?2,219569,220133#msg-220133)**
>
> Hi I have seen sometimes that google dns has banned my servers. Since I use proxy hostnames instead of ips, does the nginx cache the response from dns servers or queries them everytime it receives a request? Regards

---

<div class="post-metadata">

**Author:** ![mojiz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a87d85/32.png) [@mojiz](https://www.ruby-forum.com/u/mojiz)\
**Post date:** [December 16, 2011, 11:56am UTC](https://www.ruby-forum.com/t/does-nginx-have-resolve-cache/214513/4 "2011-12-16T11:56:39Z")

</div>

Hello!

On Thu, Dec 15, 2011 at 05:18:55PM -0500, aficionado wrote:

> ```
> set $myserver "myserver:1000";
> proxy_pass http://$myserver;
> proxy_redirect http://myserver.mydomain.in:8000
> 
> ```
> 
> [https://www.myserver.com](https://www.myserver.com);  
> }

Yes.

> 1. If I receive 100 request in 50 seconds and have my DNS (127.0.0.4)  
> returning records with TTL=1. How many request to my DNS should Nginx  
> perform in that period?

With one worker process - about 10 DNS requests, assuming the  
above config.

Maxim D.
