### wait0 Configuration Example (wait0.yaml) Source: https://github.com/devforth/wait0/blob/main/README.md This is an example configuration file for wait0, written in YAML. It defines storage settings (RAM and disk limits), server configurations (port and origin), caching rules with path matching and expiration, URL discovery options for sitemaps, and logging preferences for statistics and warmup events. ```yaml storage: # request path is cached as RAM->disk->origin, stops at first hit ram: max: '100m' # buffer for LRU cache, in fact RSS might be higher due to Go overhead disk: max: '1g' server: # wait0 listens on this port and proxies to origin port: 8082 origin: 'http://localhost:8080' rules: - match: PathPrefix(/api) | PathPrefix(/admin) priority: 1 bypass: true - match: PathPrefix(/) priority: 2 bypassWhenCookies: - sessionid # serves instantly, but if cache is stale, # it sends request to origin and updates cache expiration: '1m' # automatic scheduller which checks all known URLs in origin warmUp: runEvery: '10m' maxRequestsAtATime: 5 urlsDiscover: # optional: pre-discover URLs from sitemap(s) and seed them as inactive cache keys # so warmUp can fetch them without any user visiting first. # (historical typo "initalDelay" is supported) initalDelay: '20s' rediscoverEvery: '10m' sitemaps: - https://example.com/sitemap.xml logging: # use this to analyze cache and RAM stats, e.g: # 2026-02-08 13:56:15 2026/02/08 11:56:15.116381 Cached: Paths: 7010, RAM usage: 6.4mb, Disk usage: 6.4mb, RSS: 136.7mb, RSSRollup: 138.1mb, RSSSplit: anon=132.1mb file=n/a shmem=n/a, GoAlloc: 73.1mb, Resp Min/avg/max 0b/0b/0b log_stats_every: '1m' # log warmup stats for each rule after a warmup batch drains: # 2026-02-08 13:56:09 2026/02/08 11:56:09.053192 Revalidated for match "PathPrefix(/)": 7010 URLs (unchanged=0 updated=2000 deleted=0 ignoredStatus=0 ignoredCC=0 errors=5010 updated+errors=7010), Took: 2.081s, RPS: 3367.34, resp time min/avg/max - 27ms/248ms/1.898s log_warmup: true # log url autodiscovery stats per-sitemap when urlsDiscover is enabled # urlsDiscover sitemap="https://.../sitemap.xml" urls=123 fit=120 ignored=3 log_url_autodiscover: true ``` -------------------------------- ### Docker Deployment Examples (docker-compose.yml, Dockerfile) Source: https://context7.com/devforth/wait0/llms.txt Demonstrates deploying wait0 using Docker. Includes a docker-compose.yml file to set up wait0 and a backend application, and a custom Dockerfile to embed the configuration directly. Shows how to expose ports and mount volumes for configuration. ```yaml # docker-compose.yml services: wait0: image: devforth/wait0:latest ports: - "8082:8082" volumes: - ./wait0.yaml:/wait0.yaml:ro # Your backend application backend: image: your-nextjs-app:latest ports: - "8080:8080" ``` ```dockerfile # Custom Dockerfile with embedded config FROM devforth/wait0:latest ADD wait0.yaml /wait0.yaml EXPOSE 8082 ``` -------------------------------- ### Run Wait0 Tests and Application Source: https://github.com/devforth/wait0/blob/main/README.md Commands to execute unit tests for the Wait0 project and to run the application with a specified configuration file. These are essential for verifying functionality and starting the service. ```bash go test ./... go run ./cmd/wait0 -config ./wait0.yaml ``` -------------------------------- ### Testing wait0 Cache Behavior with curl Source: https://context7.com/devforth/wait0/llms.txt Provides examples of using curl to test wait0's cache behavior. Demonstrates how to check response headers for cache status (miss, hit, bypass, ignore-by-cookie, ignore-by-status) and how these headers change based on request parameters like URL paths and cookies. ```bash # Build and run docker compose up -d # Test cache behavior curl -i http://localhost:8082/page # Response headers include: # X-Wait0: miss (first request) # X-Wait0: hit (subsequent requests) # X-Wait0: bypass (for /api/* paths) # X-Wait0: ignore-by-cookie (when session cookie present) ``` -------------------------------- ### Docker Compose Restart Command for Cache Invalidation Source: https://github.com/devforth/wait0/blob/main/README.md This command demonstrates how to restart the wait0 service within a Docker Compose setup. Restarting the service clears both RAM and disk caches, ensuring that stale HTML referencing old static assets is removed after a redeploy. ```yaml docker compose restart wait0 ``` -------------------------------- ### Run Wait0 from Source (Bash) Source: https://context7.com/devforth/wait0/llms.txt Provides commands for building and running Wait0 directly from Go source code, including running tests, executing with a custom configuration file, and debugging using Docker Compose. ```bash # Run tests go test ./... # Run with custom config go run ./cmd/wait0 -config ./wait0.yaml # Debug with local backend cd debug docker compose -f debug-compose.yml up -d bash debug.sh # Test both origin and cached responses curl -i http://localhost:8080/test # Direct to origin curl -i http://localhost:8082/test # Through wait0 cache ``` -------------------------------- ### Configure Wait0 via Environment Variables (Bash) Source: https://context7.com/devforth/wait0/llms.txt Demonstrates how to configure Wait0's runtime behavior using environment variables. Key variables include the configuration file path, disk cache invalidation on startup, and whether to send revalidation markers. ```bash # Configuration file path (default: /wait0.yaml) WAIT0_CONFIG=/custom/path/config.yaml # Invalidate disk cache on startup (default: true) # Set to false to persist cache across restarts WAIT0_INVALIDATE_DISK_CACHE_ON_START=false # Send revalidation markers to origin (default: true) # Adds X-Wait0-Revalidate-At and X-Wait0-Revalidate-Entropy headers WAIT0_SEND_REVALIDATE_MARKERS=true ``` -------------------------------- ### Advanced Cache Rule Matching (wait0.yaml) Source: https://context7.com/devforth/wait0/llms.txt Illustrates complex caching rules using `PathPrefix()` matchers and the `|` (OR) operator in wait0.yaml. Shows how to bypass specific paths (API, auth), bypass based on cookies for certain routes, and set default caching policies with expiration and warm-up configurations. ```yaml rules: # Bypass authentication and API endpoints (never cache) - match: PathPrefix(/api) | PathPrefix(/auth) | PathPrefix(/admin) priority: 1 bypass: true # Cache static pages, bypass for logged-in users - match: PathPrefix(/blog) | PathPrefix(/docs) priority: 2 bypassWhenCookies: - auth_token - session_id expiration: '5m' # Default caching rule for everything else - match: PathPrefix(/) priority: 10 expiration: '2m' warmUp: runEvery: '5m' maxRequestsAtATime: 10 ``` -------------------------------- ### Docker Compose Configuration with Environment Variables (YAML) Source: https://context7.com/devforth/wait0/llms.txt Shows a docker-compose.yml snippet for running Wait0 as a service, including how to set environment variables for configuration and mount the configuration file. ```yaml services: wait0: image: devforth/wait0:latest environment: - WAIT0_CONFIG=/wait0.yaml - WAIT0_INVALIDATE_DISK_CACHE_ON_START=true volumes: - ./wait0.yaml:/wait0.yaml:ro ``` -------------------------------- ### Configure URL Discovery from Sitemaps (YAML) Source: https://context7.com/devforth/wait0/llms.txt Defines the configuration for discovering URLs from sitemaps to pre-seed the cache. It includes settings for initial delay, re-discovery frequency, and a list of sitemap URLs, supporting both regular and gzipped sitemaps. ```yaml urlsDiscover: initialDelay: '30s' rediscoverEvery: '1h' sitemaps: - https://example.com/sitemap.xml - https://example.com/sitemap-posts.xml.gz ``` -------------------------------- ### Dockerfile for wait0 Deployment Source: https://github.com/devforth/wait0/blob/main/README.md This Dockerfile sets up a basic environment for wait0. It uses the official wait0 image, adds a custom configuration file named wait0.yaml, and exposes the default port 8082. ```yaml FROM devforth/wait0:latest ADD wait0.yaml /wait0.yaml EXPOSE 8082 ``` -------------------------------- ### Sitemap XML Formats Source: https://context7.com/devforth/wait0/llms.txt Illustrates the supported XML formats for sitemaps, including the standard sitemap.xml structure and the sitemap index format, which allows for referencing multiple sitemap files. ```xml https://example.com/page1 https://example.com/page2 https://example.com/sitemap-pages.xml https://example.com/sitemap-posts.xml ``` -------------------------------- ### Debug Wait0 and Origin Services Source: https://github.com/devforth/wait0/blob/main/README.md Shell script and curl commands to initiate debugging and retrieve logs from the origin and Wait0 services. This helps in diagnosing issues by inspecting the state and output of both components. ```bash bash debug/debug.sh # get origin and wait0 logs: curl -i http://localhost:8080/xx curl -i http://localhost:8082/xx ``` -------------------------------- ### wait0 Diagnostic Response Headers Source: https://context7.com/devforth/wait0/llms.txt Details the diagnostic `X-Wait0` headers added by wait0 to HTTP responses. Explains the meaning of `miss`, `hit`, `bypass`, `ignore-by-cookie`, and `ignore-by-status`, along with revalidation timestamps and discovery sources, aiding in cache debugging. ```bash # Cache miss (first request) curl -i http://localhost:8082/page # X-Wait0: miss # X-Wait0-Discovered-By: user # Cache hit (subsequent requests) curl -i http://localhost:8082/page # X-Wait0: hit # X-Wait0-Revalidated-At: 2024-01-15T10:30:00.123456789Z # X-Wait0-Revalidated-By: user # Bypassed request (API path or cookie match) curl -i http://localhost:8082/api/data # X-Wait0: bypass curl -i -H "Cookie: sessionid=abc123" http://localhost:8082/page # X-Wait0: ignore-by-cookie # Non-2xx response (cache invalidated) # X-Wait0: ignore-by-status ``` -------------------------------- ### Docker Compose for wait0 Service (Image) Source: https://github.com/devforth/wait0/blob/main/README.md This Docker Compose configuration defines a 'wait0' service using a pre-built image. It maps the host port 8082 to the container's port 8082 and mounts a local wait0.yaml configuration file as read-only. ```yaml services: wait0: image: devforth/wait0:latest ports: - "8082:8082" volumes: - "./wait0.yaml:/wait0.yaml:ro" ``` -------------------------------- ### Docker Compose for wait0 Service (Build) Source: https://github.com/devforth/wait0/blob/main/README.md This Docker Compose configuration defines a 'wait0' service that is built from a Dockerfile. It maps the host port 8082 to the container's port 8082, allowing external access to the proxy. ```yaml services: wait0: build: . ports: - "8082:8082" ``` -------------------------------- ### Invalidate Wait0 Cache (Bash) Source: https://context7.com/devforth/wait0/llms.txt Demonstrates methods for invalidating Wait0's cache, including restarting the Docker container to clear RAM and disk caches, or recreating the container to achieve the same effect. ```bash # Restart wait0 to clear all caches (RAM + disk) docker compose restart wait0 # Or recreate the container docker compose up -d --force-recreate wait0 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.