Zigly
January 20, 2026 · View on GitHub
Zigly is a Zig library for building Fastly Compute services. It provides high-level bindings for Fastly's edge computing platform, targeting WebAssembly.
Why Zig?
Fastly Compute bills based on execution time and memory usage. The Zig compiler produces WebAssembly modules that are exceptionally small, fast, and memory-efficient—often significantly smaller than equivalent Rust code, and orders of magnitude smaller than JavaScript bundles.
This translates directly to lower costs: smaller binaries mean faster cold starts, less memory overhead, and reduced execution time.
Quick Example
const zigly = @import("zigly");
pub fn main() !void {
var downstream = try zigly.downstream();
// Option 1: Proxy to a backend
try downstream.proxy("origin", "api.example.com");
// Option 2: Build a custom response
// try downstream.response.setStatus(200);
// try downstream.response.body.writeAll("Hello from the edge!");
// try downstream.response.finish();
}
Features
- HTTP handling - Full request/response manipulation with headers and bodies
- Caching - Simple and transactional cache APIs with TTL and stale-while-revalidate
- Rate limiting - Edge rate limiting with rate counters and penalty boxes
- Geolocation - IP-based location lookup
- Device detection - Identify mobile, tablet, and desktop devices
- Backends - Static and dynamic backend management with SSL support
- KV store - Key-value storage at the edge
- ACLs - IP-based access control lists
- Logging - Send logs to external endpoints
- Purging - Invalidate cached content by surrogate key
Documentation
Getting Started
- Installation - Add Zigly to your project
- Hello World - Build your first edge service
- Testing Locally - Run services locally
- Deployment - Deploy to Fastly Compute
Concepts
- Architecture - How Zigly maps to Fastly APIs
- Error Handling - Working with FastlyError
- Memory Management - Allocator patterns
Guides
- Proxying - CDN proxy patterns
- Caching - Cache strategies
- Rate Limiting - Protect your origins
- Geo Routing - Location-based routing
- Device Detection - Mobile optimization
API Reference
- HTTP - Request, Response, Headers, Body, Downstream
- Cache - Simple and transactional caching
- Backend - Static and dynamic backends
- ERL - Rate limiting
- KV Store - Key-value storage
- Geo - Geolocation
- Device - Device detection
- Dictionary - Edge dictionaries
- ACL - Access control lists
- Logger - Logging endpoints
- Purge - Cache purging
- User Agent - UA parsing
- Runtime - vCPU metrics
Examples
- Simple Proxy - Basic CDN proxy
- API Gateway - Multi-backend routing
- Rate Limiter - IP-based rate limiting
- Geo Redirect - Country-based redirects
Requirements
- Zig 0.16.0 or later
- Local testing: Viceroy or Fastlike
- Fastly CLI for deployment
License
See the repository for license information.