An open API service indexing awesome lists of open source software.

https://github.com/omalloc/tavern

🚀 A high-performance CDN caching engine written in Go, designed for ultra-low latency content delivery and multi-level cache eviction strategies.
https://github.com/omalloc/tavern

caching cdn go http http-cache http-proxy

Last synced: 10 days ago
JSON representation

🚀 A high-performance CDN caching engine written in Go, designed for ultra-low latency content delivery and multi-level cache eviction strategies.

Awesome Lists containing this project

README

          

Tavern



Build Status
GoDoc
codeCov
Report Card
License



Tavern is a high-performance HTTP caching proxy server implemented in Go. It leverages a modern service framework to deliver a flexible architecture, strong extensibility, and excellent performance.

Other languages: [įŽ€äŊ“中文](README.zh-CN.md)

## ✨ Features

- **Core Caching Capabilities**:
- [x] Prefetch
- [x] Cache Push (URL/DIR Push)
- [x] URL mark expired
- [x] URL cache file delete
- [x] DIR mark expired
- [x] DIR cache file delete
- [x] Fuzzy refresh (Fuzzing fetch)
- [x] Auto refresh
- [x] Cache validation
- [ ] Hot migration
- [ ] Warm/cold split
- [x] Upstream collapse request (request coalescing)
- [ ] ~~Image compression adaptation (WebP support)~~
- [x] Vary-based versioned cache (Vary cache)
- [x] Headers rewrite
- [x] Multiple Range requests support
- [x] CacheFile verification (CRC checksum / EdgeMode)
- **Modern Architecture**:
- Built on the **Kratos** framework for high extensibility and module reuse
- **Plugin System**: Extend core business logic via plugins
- **Storage Layer**: Decoupled storage backend with memory, disk, and custom implementations
- **Reliability & Operations**:
- **Graceful Upgrade**: Zero-downtime config reload and binary upgrade
- **Failure Recovery**: Built-in panic recovery and error handling
- **Observability**: Native Prometheus metrics and PProf profiling
- **Traffic Control**:
- Header rewrite (Rewrite)
- Upstream load balancing (via custom Selector)

## Ecosystem

- Cache CRC verification service: [CRC-Center](https://github.com/omalloc/trust-receive)

## 🚀 Quick Start

### Requirements

- Go 1.24+
- Linux/macOS (Graceful restart may be limited on Windows)

### 1. Fetch & Configure

Clone the repository and prepare the configuration file:

```bash
git clone https://github.com/omalloc/tavern.git
cd tavern

# Initialize with example configuration
cp config.example.yaml config.yaml
```

### 2. Run the Service

**Development mode:**

```bash
# Loads config.yaml from the current directory by default
go run main.go
```

**Build and run:**

```bash
make build
./bin/tavern -c config.yaml
```

### 3. Debugging & Monitoring

Once started, you can monitor and debug using the following (ports depend on `config.yaml`):

- **Metrics**: Access `/metrics` for Prometheus metrics (default prefix `tr_tavern_`)
- **PProf**: When debug mode is enabled, visit `/debug/pprof/` for profiling

## 🧩 Project Structure

- `api/`: Protocol and interface definitions
- `conf/`: Configuration definitions and parsing
- `plugin/`: Plugin interfaces and implementations
- `proxy/`: Core proxy and forwarding logic
- `server/`: HTTP server implementation and middleware
- `storage/`: Storage engine abstractions and implementations

## 📚 Documentation

- PURGE design and operations: [docs/purge.md](docs/purge.md)

## 📝 License

[MIT License](LICENSE)

## 🙏 Acknowledgments

This project integrates and is inspired by the following excellent open-source projects. Many thanks:

- **[Kratos](https://github.com/go-kratos/kratos)**: A powerful microservice framework that inspired Tavern's modern architecture.
- **[Pebble](https://github.com/cockroachdb/pebble)**: A high-performance key-value store by CockroachDB, powering efficient persistent caching.
- **[tableflip](https://github.com/cloudflare/tableflip)**: Cloudflare's graceful upgrade solution enabling zero-downtime restarts.
- **[Prometheus Go Client](https://github.com/prometheus/client_golang)**: Strong observability support for metrics.