apiserver/vendor/github.com/gregjones/httpcache
Kubernetes Publisher eb9bb8285d Merge pull request #50404 from apelisse/http-cache
Automatic merge from submit-queue (batch tested with PRs 51480, 49616, 50123, 50846, 50404)

Kubectl to use http caching to cache openapi responses from the server

**What this PR does / why we need it**:

This PR is trying to address the problems raised in #50254

> * uses a disk-based cache that is not safe between processes (does not use atomic fs operations)
> * writes get/list responses to disk that should not be cached (like kubectl get secrets)
> * is vulnerable to partially written cache responses being used as responses to future requests
> * breaks uses of the client transport that make use of websockets
> * defaults to enabling the cache for any client builder using RecommendedConfigOverrideFlags or DefaultClientConfig which affects more components than just kubectl

All of these points are addressed by this pull-request:
1. It now uses atomic fs operations
2. Doesn't cache by default, only if requested by the client (and it's only done by openapi client)
3. Fixed because of atomic fs operations
4. Found the reason for the bug: Cache wrapper couldn't be unwrapped. I implemented the `WrappedRoundTripper` interface.
5. Since 2. is fixed, I think that should be fine

@smarterclayton @liggitt

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #50254

**Special notes for your reviewer**:

**Release note**:

```release-note
Allows kubectl to use http caching mechanism for the OpenAPI schema. The cache directory can be configured through `--cache-dir` command line flag to kubectl. If set to empty string, caching will be disabled.
```

Kubernetes-commit: 0f2c2bd847ca7a66035b2289e83359ef4c923617
2017-09-01 16:38:01 +00:00
..
diskcache Merge pull request #50404 from apelisse/http-cache 2017-09-01 16:38:01 +00:00
.travis.yml Merge pull request #50404 from apelisse/http-cache 2017-09-01 16:38:01 +00:00
LICENSE.txt Merge pull request #50404 from apelisse/http-cache 2017-09-01 16:38:01 +00:00
README.md Merge pull request #50404 from apelisse/http-cache 2017-09-01 16:38:01 +00:00
httpcache.go Merge pull request #50404 from apelisse/http-cache 2017-09-01 16:38:01 +00:00

README.md

httpcache

Build Status GoDoc

Package httpcache provides a http.RoundTripper implementation that works as a mostly RFC-compliant cache for http responses.

It is only suitable for use as a 'private' cache (i.e. for a web-browser or an API-client and not for a shared proxy).

Cache Backends

License