113 lines
3.3 KiB
Groff
113 lines
3.3 KiB
Groff
.\" generated with Ronn/v0.7.3
|
|
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
|
.
|
|
.TH "COREDNS\-CACHE" "7" "February 2018" "CoreDNS" "CoreDNS plugins"
|
|
.
|
|
.SH "NAME"
|
|
\fIcache\fR \- enables a frontend cache\.
|
|
.
|
|
.SH "DESCRIPTION"
|
|
With \fIcache\fR enabled, all records except zone transfers and metadata records will be cached for up to 3600s\. Caching is mostly useful in a scenario when fetching data from the backend (upstream, database, etc\.) is expensive\.
|
|
.
|
|
.SH "SYNTAX"
|
|
.
|
|
.nf
|
|
|
|
cache [TTL] [ZONES\.\.\.]
|
|
.
|
|
.fi
|
|
.
|
|
.IP "\(bu" 4
|
|
\fBTTL\fR max TTL in seconds\. If not specified, the maximum TTL will be used, which is 3600 for noerror responses and 1800 for denial of existence ones\. Setting a TTL of 300: \fBcache 300\fR would cache records up to 300 seconds\.
|
|
.
|
|
.IP "\(bu" 4
|
|
\fBZONES\fR zones it should cache for\. If empty, the zones from the configuration block are used\.
|
|
.
|
|
.IP "" 0
|
|
.
|
|
.P
|
|
Each element in the cache is cached according to its TTL (with \fBTTL\fR as the max)\. For the negative cache, the SOA\'s MinTTL value is used\. A cache can contain up to 10,000 items by default\. A TTL of zero is not allowed\.
|
|
.
|
|
.P
|
|
If you want more control:
|
|
.
|
|
.IP "" 4
|
|
.
|
|
.nf
|
|
|
|
cache [TTL] [ZONES\.\.\.] {
|
|
success CAPACITY [TTL]
|
|
denial CAPACITY [TTL]
|
|
prefetch AMOUNT [[DURATION] [PERCENTAGE%]]
|
|
}
|
|
.
|
|
.fi
|
|
.
|
|
.IP "" 0
|
|
.
|
|
.IP "\(bu" 4
|
|
\fBTTL\fR and \fBZONES\fR as above\.
|
|
.
|
|
.IP "\(bu" 4
|
|
\fBsuccess\fR, override the settings for caching successful responses\. \fBCAPACITY\fR indicates the maximum number of packets we cache before we start evicting (\fIrandomly\fR)\. \fBTTL\fR overrides the cache maximum TTL\.
|
|
.
|
|
.IP "\(bu" 4
|
|
\fBdenial\fR, override the settings for caching denial of existence responses\. \fBCAPACITY\fR indicates the maximum number of packets we cache before we start evicting (LRU)\. \fBTTL\fR overrides the cache maximum TTL\. There is a third category (\fBerror\fR) but those responses are never cached\.
|
|
.
|
|
.IP "\(bu" 4
|
|
\fBprefetch\fR will prefetch popular items when they are about to be expunged from the cache\. Popular means \fBAMOUNT\fR queries have been seen with no gaps of \fBDURATION\fR or more between them\. \fBDURATION\fR defaults to 1m\. Prefetching will happen when the TTL drops below \fBPERCENTAGE\fR, which defaults to \fB10%\fR, or latest 1 second before TTL expiration\. Values should be in the range \fB[10%, 90%]\fR\. Note the percent sign is mandatory\. \fBPERCENTAGE\fR is treated as an \fBint\fR\.
|
|
.
|
|
.IP "" 0
|
|
.
|
|
.SH "METRICS"
|
|
If monitoring is enabled (via the \fIprometheus\fR directive) then the following metrics are exported:
|
|
.
|
|
.IP "\(bu" 4
|
|
\fBcoredns_cache_size{type}\fR \- Total elements in the cache by cache type\.
|
|
.
|
|
.IP "\(bu" 4
|
|
\fBcoredns_cache_capacity{type}\fR \- Total capacity of the cache by cache type\.
|
|
.
|
|
.IP "\(bu" 4
|
|
\fBcoredns_cache_hits_total{type}\fR \- Counter of cache hits by cache type\.
|
|
.
|
|
.IP "\(bu" 4
|
|
\fBcoredns_cache_misses_total{}\fR \- Counter of cache misses\.
|
|
.
|
|
.IP "" 0
|
|
.
|
|
.P
|
|
Cache types are either "denial" or "success"\.
|
|
.
|
|
.SH "EXAMPLES"
|
|
Enable caching for all zones, but cap everything to a TTL of 10 seconds:
|
|
.
|
|
.IP "" 4
|
|
.
|
|
.nf
|
|
|
|
\&\. {
|
|
cache 10
|
|
whoami
|
|
}
|
|
.
|
|
.fi
|
|
.
|
|
.IP "" 0
|
|
.
|
|
.P
|
|
Proxy to Google Public DNS and only cache responses for example\.org (or below)\.
|
|
.
|
|
.IP "" 4
|
|
.
|
|
.nf
|
|
|
|
\&\. {
|
|
proxy \. 8\.8\.8\.8:53
|
|
cache example\.org
|
|
}
|
|
.
|
|
.fi
|
|
.
|
|
.IP "" 0
|
|
|