项目作者: panoplymedia

项目描述 :
Reverse Proxy in Go
高级语言: Go
项目地址: git://github.com/panoplymedia/httpcache.git
创建时间: 2018-02-11T17:02:01Z
项目社区:https://github.com/panoplymedia/httpcache

开源协议:MIT License

下载


HTTP Cache

Description

HTTP Cache is a caching reverse-proxy. It’s a way to simulate a CDN like Cloudflare or Fastly on your development environment.

Installation

  1. go get -u github.com/panoplymedia/httpcache

Example Usage

We would like to cache the output of our local server that is serving audio (mp3) files. Let’s say that our local server runs on port 8080. We will run the cache on port 3003 (any open port will do).

  1. httpcache --port=3003 --origin=http://localhost:8080

Now we can point any other service that is using our audio service to port 3003, our local caching service, instead of our actual service that is running at 8080.

Now requests will be routed as follows:

  • http://localhost:3003/audio/first.mp3 cache miss -> http://localhost:8080/audio/first.mp3
  • http://localhost:3003/audio/first.mp3 cache hit -> cached file
  • http://localhost:3003/audio/second.mp3 cache miss -> http://localhost:8080/audio/second.mp3

Help

  1. httpcache --help

Notes

The cache is transient, in that it will reset it’s state after every run. So if it’s running and you kill it, when you start it back up, it’s cache will be empty.