A public, serverless Prebid Cache instance on Google Cloud Run

Scales to zero • Pay per request • ~$0-15/mo

This Instance

Hosting
Cloud Run
Storage
Upstash Redis
Max TTL
3 Hours
Max Size
100 KB

API Usage

Prebid Cache stores short-term data (typically video ad markup or JSON bid responses) and returns a UUID that can be used to retrieve it.

Store a value — POST /cache

curl -X POST https://prebid.video/cache \
  -H "Content-Type: application/json" \
  -d '{
    "puts": [
      {
        "type": "json",
        "value": {"adm":"<VAST>...</VAST>","nurl":"https://example.com"}
      }
    ]
  }'

Response:

{
  "responses": [
    {"uuid": "d4e5f678-1234-5678-9abc-def012345678"}
  ]
}

Retrieve a value — GET /cache?uuid=...

curl https://prebid.video/cache?uuid=d4e5f678-1234-5678-9abc-def012345678

Store XML (VAST) content

curl -X POST https://prebid.video/cache \
  -H "Content-Type: application/json" \
  -d '{
    "puts": [
      {
        "type": "xml",
        "value": "<VAST version=\"3.0\">...</VAST>",
        "ttlseconds": 3600
      }
    ]
  }'

Optional fields per entry: ttlseconds (max 10800), key (if allowed by config), type ("json" or "xml").

Deploy Your Own Instance

Running your own Prebid Cache on Cloud Run takes about 15 minutes and costs $0-15/month. Here's how:

1. Prerequisites

2. Set Up Upstash Redis

  1. Create a free account at upstash.com
  2. Create a new Redis database (choose the region closest to your Cloud Run region)
  3. Note the Endpoint (host), Port, and Password from the database details page

3. Set Up GCP

# Set your project
gcloud config set project YOUR_PROJECT_ID

# Enable required APIs
gcloud services enable run.googleapis.com artifactregistry.googleapis.com cloudbuild.googleapis.com

# Create an Artifact Registry repository
gcloud artifacts repositories create prebid-cache \
  --repository-format=docker \
  --location=us-central1

4. Build & Deploy

# Clone the repo
git clone https://github.com/headertag/prebid-cache.git
cd prebid-cache

# Build remotely with Cloud Build and deploy to Cloud Run
export GCP_PROJECT_ID=your-project-id
export REDIS_HOST=your-upstash-endpoint
export REDIS_PORT=6379
export REDIS_PASSWORD=your-upstash-password

./deploy/deploy.sh

5. Map a Custom Domain (Optional)

# Map your domain
gcloud run domain-mappings create \
  --service prebid-cache \
  --domain your-domain.com \
  --region us-central1

# Then add the DNS records shown by the command above

Cloud Run provides free, auto-renewing Google-managed SSL certificates. No Let's Encrypt setup is needed.

6. Verify

# Store a test value
curl -X POST https://YOUR_CLOUD_RUN_URL/cache \
  -H "Content-Type: application/json" \
  -d '{"puts":[{"type":"json","value":{"test":true}}]}'

# Retrieve it using the returned UUID
curl https://YOUR_CLOUD_RUN_URL/cache?uuid=RETURNED_UUID

Architecture & Costs

ComponentMonthly CostNotes
Cloud Run$0–5min-instances=0, scales to zero, generous free tier
Upstash Redis$0–10Serverless pay-per-request, free tier included
SSL Certificate$0Google-managed, auto-renewing
Artifact Registry$00.5GB free tier covers the Docker image
Total$0–15Only costs more under heavy traffic

Why Upstash Redis over Google Memorystore? Memorystore starts at ~$160/month minimum even when idle. Upstash is truly serverless — $0 when no requests are made. It speaks standard Redis protocol, so it works with the existing go-redis/redis/v8 client in prebid-cache with TLS support.

Configuration Reference

Prebid Cache reads configuration from config.yaml and environment variables prefixed with PBC_. Environment variables take precedence and use underscores instead of dots (e.g., PBC_BACKEND_TYPE=redis).

Env VariableDescriptionExample
PBC_BACKEND_TYPEStorage backendredis
PBC_BACKEND_REDIS_HOSTRedis hostus1-xxx.upstash.io
PBC_BACKEND_REDIS_PORTRedis port6379
PBC_BACKEND_REDIS_PASSWORDRedis passwordyour-password
PBC_BACKEND_REDIS_TLS_ENABLEDEnable TLStrue
PBC_REQUEST_LIMITS_MAX_TTL_SECONDSMax TTL for cached values10800

Links