Index | Files

package httpcache

import ""

Package httpcache provides a RoundTripper that stores all responses on disk, and returns cached responses for any requests that have been made before. This package is provided for a very specific purpose, and is unlikely to be widely useful. Be aware of the caveats before using this package: - Requests are keyed purely based on the URL. All other data from the request

are ignored, which includes headers, POST data, and even query parameters.

- Responses are cached *forever* (until manually deleted).

This cache is useful for quickly prototyping bar customisations. By replacing the Transport of http.DefaultClient (or replacing http.DefaultTransport), the resulting binary will no longer make real HTTP requests when started, so it can be rebuilt and restarted hundreds of times without counting towards any quota.

The cache is located at ~/.cache/barista/http (using XDG_CACHE_HOME for ~/.cache if set). Individual responses can be deleted if a fresher copy is needed.


Package Files


func Wrap Uses

func Wrap(transport http.RoundTripper) http.RoundTripper

Wrap creates a new caching http.RoundTripper that uses the given RoundTripper to fetch responses that don't yet exist in the cache.

Package httpcache imports 10 packages (graph) and is imported by 1 packages. Updated 2018-10-16. Refresh now. Tools for package owners.