Commit graph

11 commits

Author SHA1 Message Date
AllenZMC
8ab83a175a fix mis-spelling in item.go (#3156) 2019-08-19 09:36:59 -04:00
Miek Gieben
481dea50ad
plugin/cache: remove item.Autoritative (#2885)
* plugin/cache: remove item.Autoritative

Confuses clients if not set; remove it.

Signed-off-by: Miek Gieben <miek@miek.nl>

* Add extra comments on why we do this

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-06-13 10:36:47 +01:00
Miek Gieben
dae506b563
Fix max-age in http server (#1890)
* 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-27 21:12:27 +01:00
Miek Gieben
68b45f5377
plugin/cache: unroll minTTL loop (#1773)
This allocates memory because of the append, just unroll the loop.
Also add benchmark.

Before:
goos: linux
goarch: amd64
pkg: github.com/coredns/coredns/plugin/cache
BenchmarkCacheResponse-4   	  100000	     11910 ns/op
BenchmarkMinMsgTTL-4       	 1000000	      1494 ns/op
PASS

After:
goos: linux
goarch: amd64
pkg: github.com/coredns/coredns/plugin/cache
BenchmarkCacheResponse-4   	  100000	     12016 ns/op
BenchmarkMinMsgTTL-4       	 2000000	       668 ns/op
PASS
2018-05-08 18:36:29 +01:00
Miek Gieben
565e416407
plugin/cache: don't recheck the OPT records (#1772)
These are not stored with newItem so we don't have to check them later.
2018-05-08 18:36:08 +01:00
Miek Gieben
5735292406
Do Compress only when need in request.Scrub (#1760)
* Remove Compress by default

Set Compress = true in Scrub only when the message doesn not fit the
advertized buffer. Doing compression is expensive, so try to avoid it.

Master vs this branch
pkg: github.com/coredns/coredns/plugin/cache
BenchmarkCacheResponse-2   	   50000	     24774 ns/op

pkg: github.com/coredns/coredns/plugin/cache
BenchmarkCacheResponse-2   	  100000	     21960 ns/op

* and make it compile
2018-05-01 21:04:06 +01:00
Chris O'Haver
aa2302e3f4 incl addtl rrs when computing cache ttl (#1549) 2018-02-21 21:02:49 +00:00
Miek Gieben
8cce06cba1
Type.extra (#1538)
* Revert "pkg/typify: empty messages are OtherError (#1531)"

This reverts commit fc1d73ffa9.

* 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-17 19:45:52 +01:00
Tobias Schmidt
dd9fc8962c plugin/cache: Fix prefetching issues (#1363)
* 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-17 07:35:22 +00:00
Tobias Schmidt
f1b280de53 Remove TTL ceiling at 5s in plugin/cache (#1380)
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.
2018-01-11 17:06:49 +00:00
Miek Gieben
d8714e64e4 Remove the word middleware (#1067)
* 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
2017-09-14 09:36:06 +01:00
Renamed from middleware/cache/item.go (Browse further)