httpcontrol: Index | Files

package httpcache

import ""

Package httpcache provides a cache enabled http Transport.


Package Files


type ByteCache Uses

type ByteCache interface {
    Store(key string, value []byte, timeout time.Duration) error
    Get(key string) ([]byte, error)

type Config Uses

type Config interface {
    // Generates the cache key for the given http.Request. An empty string will
    // disable caching.
    Key(req *http.Request) string

    // Provides the max cache age for the given request/response pair. A zero
    // value will disable caching for the pair. The request is available via
    // res.Request.
    MaxAge(res *http.Response) time.Duration

func CacheByPath Uses

func CacheByPath(timeout time.Duration) Config

This caches against the host + path (ignoring scheme, auth, query etc) for the specified duration.

func CacheByURL Uses

func CacheByURL(timeout time.Duration) Config

This caches against the entire URL for the specified duration.

type Transport Uses

type Transport struct {
    Config    Config            // Provides cache key & timeout logic.
    ByteCache ByteCache         // Cache where serialized responses will be stored.
    Transport http.RoundTripper // The underlying http.RoundTripper for actual requests.

Cache enabled http.Transport.

func (*Transport) RoundTrip Uses

func (t *Transport) RoundTrip(req *http.Request) (res *http.Response, err error)

A cache enabled RoundTrip.

Package httpcache imports 5 packages (graph). Updated 2017-09-08. Refresh now. Tools for package owners.