aboutsummaryrefslogtreecommitdiff
path: root/plugin/cache/cache.go (follow)
AgeCommit message (Collapse)AuthorFilesLines
2019-02-17Fix some typos (#2560)Gravatar Nguyen Quang Huy 1-1/+1
* Fix some typos Corect some words for reading more easily * Update NOERROR response code NOERROR is a response code so I revert the typo checking for it
2018-10-29cache: some optimizations (#2247)Gravatar Miek Gieben 1-18/+8
Remove some optimization and lowercasing of the qname (in the end miekg/dns should provide a fast and OK function for it). * remove the make([]byte, 2) allocation in the key() * use already lowercased qname in hash key calculation. % benchcmp old.txt new.txt benchmark old ns/op new ns/op delta BenchmarkCacheResponse-4 9599 8735 -9.00% Signed-off-by: Miek Gieben <miek@miek.nl>
2018-10-22make default min ttl 5 (#2227)Gravatar Chris O'Haver 1-2/+2
2018-10-16plugin/cache: Set min TTL default to zero (#2199)Gravatar Chris O'Haver 1-2/+2
* set min ttl default to zero * add short TTL test case
2018-09-03Add MINTTL parameter to cache configuration. (#2055)Gravatar Aaron Riekenberg 1-13/+28
* Add success min TTL parameter to cache. * Add MINTTL to README. * Update README. * Add MINTTL to negative cache. * Remove unnecessary variable name. * Address review comments. * Configure cache in TestCacheZeroTTL to have 0 min ttl.
2018-08-31Move cache Keys to 64bit for a better dispersion and lower collision ↵Gravatar Francois Tur 1-16/+14
frequency (#2077) * - change Key for cache to 64bits. * - change Key for cache to 64bits.
2018-06-27Fix max-age in http server (#1890)Gravatar Miek Gieben 1-4/+4
* Fix max-age in http server Move the minMsgTTL to dnsutil and rename it MinimalTTL, move some constants there as well. Use these new function in server_https to correctly set the max-age HTTP header. Fixes: #1823 * Linter
2018-06-19Ensure cache.ResponseWriter can be used asynchronously during prefetch (#1884)Gravatar Tobias Schmidt 1-1/+35
The default dns.Response implementation of a dns.ResponseWriter will panic if RemoteAddr() is called after the connection to the client has been closed already. The current cache implementation doesn't create a new request+responsewriter during an asynchronous prefetch, but piggybacks on the request triggering the prefetch. This change copies the RemoteAddr first, so that it's safe to use it later during the actual prefetch request. A better implementation would be to completely decouple the prefetch request from the client triggering a request.
2018-05-09request.Match check Response bit as well (#1775)Gravatar Miek Gieben 1-1/+0
* request.Match check Response bit as well We should check this bit and reject them as invalid. * Fix test
2018-04-27Cache metrics server (#1746)Gravatar Miek Gieben 1-4/+5
* plugin/cache: per server metrics Use per server metrics in the cache plugin as well. This required some plumbing changes. Also use request.Request more. * fix cherry-pick
2018-04-22Use logging (#1718)Gravatar Miek Gieben 1-1/+0
* update docs * plugins: use plugin specific logging Hooking up pkg/log also changed NewWithPlugin to just take a string instead of a plugin.Handler as that is more flexible and for instance the Root "plugin" doesn't implement it fully. Same logging from the reload plugin: .:1043 2018/04/22 08:56:37 [INFO] CoreDNS-1.1.1 2018/04/22 08:56:37 [INFO] linux/amd64, go1.10.1, CoreDNS-1.1.1 linux/amd64, go1.10.1, 2018/04/22 08:56:37 [INFO] plugin/reload: Running configuration MD5 = ec4c9c55cd19759ea1c46b8c45742b06 2018/04/22 08:56:54 [INFO] Reloading 2018/04/22 08:56:54 [INFO] plugin/reload: Running configuration MD5 = 9e2bfdd85bdc9cceb740ba9c80f34c1a 2018/04/22 08:56:54 [INFO] Reloading complete * update docs * better doc
2018-04-19Update all plugins to use plugin/pkg/log (#1694)Gravatar Miek Gieben 1-3/+3
* Update all plugins to use plugin/pkg/log I wish this could have been done with sed. Alas manually changed all callers to use the new plugin/pkg/log package. * Error -> Info * Add docs to debug plugin as well
2018-03-25Fix dns-01-003 (#1634)Gravatar Miek Gieben 1-3/+10
* plugin/{cache,forward,proxy}: don't allow responses that are bogus Responses that are not matching what we've been querying for should be dropped. They are converted into FormErrs by forward and proxy; as a 2nd backstop cache will also not cache these. * plug * add explicit test
2018-03-09logging: Don't use PrintF when not needed (#1599)Gravatar Miek Gieben 1-1/+1
These log print don't have any verbs, so just use plain Print
2018-02-17Type.extra (#1538)Gravatar Miek Gieben 1-3/+4
* Revert "pkg/typify: empty messages are OtherError (#1531)" This reverts commit fc1d73ffa9ae193c4cfca4adc194ae43f9360dbb. * plugin/cache: add failsafeTTL If we can not see what TTL we should put on a message to be cached, use 5 seconds as minimal TTL. We used to apply the maximum TTL to these messages.
2018-02-16pkg/typify: empty messages are OtherError (#1531)Gravatar Miek Gieben 1-1/+1
Messages with nothing in them are considered OtherError, they can not serve any purpose for normal clients (i.e. dyn update or notifies might have a use for them). Also update a test in the cache plugin, so that we explicitaly test for this case.
2018-01-17plugin/cache: Fix prefetching issues (#1363)Gravatar Tobias Schmidt 1-3/+24
* Improve plugin/cache metrics * Add coredns_cache_prefetch_total metric to track number of prefetches. * Remove unnecessary Cache.get() call which would incorrectly increment cache counters. * Initialize all counters and gauges at zero. * Allow prefetching of a single request per ttl The original implementation didn't allow prefetching queries which are only requested once during the duration of a TTL. The minimum amount of queries which had to be seen was therefore capped at 2. This change also implements a real prefetch test. The existing test was a noop and always passed regardless of any prefetch implementation. * Fix prefetching for items with a short TTL The default prefetch threshold (percentage) is 10% of the lifetime of a cache item. With the previous implementation, this disabled prefetching for all items with a TTL < 10s (the resulting percentage would be 0, at which point a cached item is already discarded). This change uses a time based threshold calculation and ensures that a prefetch is triggered at a TTL of 1 at the latest. * Fix wrong duration reporting of cached responses The logging and metrics plugins (among others) included the duration of a cache prefetch in the request latency of client request. This change fixes this wrong reporting and executes the prefetch request in a goroutine in the background.
2018-01-11Remove TTL ceiling at 5s in plugin/cache (#1380)Gravatar Tobias Schmidt 1-2/+0
The cache plugin always returned a minimum TTL of 5 seconds, regardless of the actual TTL of the records. A cache is not authoritative for the record TTL and should not extend it.
2017-09-28plugin/cache: don't cache msg with TTL=0 in them (#1116)Gravatar Miek Gieben 1-3/+2
Don't cache these - may be lead to weird side effects. Fixes #1113
2017-09-20plugin/cache: cap TTL on first answer (#1092)Gravatar Miek Gieben 1-0/+13
Cache would let the first response through and would then cap subsequent ones to whatever the cache duration was. This would lead to huge drops in TTL values: 3600 -> 20 for instance, which is not only bad, but can mess up your careful TTL planning business. This PR fixes that and applies the cache duration to all replies. As a bonus I could remove a time.Sleep() from the cache test and just check for the cache duration as the TTL on the reply. Fixes #1038
2017-09-14Remove the word middleware (#1067)Gravatar Miek Gieben 1-0/+167
* Rename middleware to plugin first pass; mostly used 'sed', few spots where I manually changed text. This still builds a coredns binary. * fmt error * Rename AddMiddleware to AddPlugin * Readd AddMiddleware to remain backwards compat