ORZ HOLDINGS
← Research Repository
OrzattyCloud Infrastructure

OrzattyCloud CDN

A sovereign, globally distributed CDN powered by Cloudflare Workers and R2 object storage. 15+ intelligent proxy routes, on-the-fly ImageXR processing, GraphQL POST caching, SRI computation, and privacy-first Google Fonts proxying.

RuntimeCloudflare Workers (V8)
StorageCloudflare R2
Domaincdn.orzatty.com
Routes15+
Contactresearch@orzatty.org

Table of Contents

  1. Abstract & Design Goals
  2. Infrastructure Stack
  3. 15+ Proxy Routes
  4. Cache Strategy
  5. ImageXR: On-the-Fly Image Processing
  6. GraphQL POST Cache
  7. SRI Computation Engine
  8. Google Fonts Privacy Proxy
  9. R2 Storage Backend
  10. Security Model

1. Abstract & Design Goals

Modern web applications depend on dozens of external CDN services — npm packages from jsDelivr, fonts from Google, icons from Iconify. Each dependency introduces latency, reliability risk, and GDPR exposure (user IPs sent to third parties).

OrzattyCloud CDN aggregates these under a single sovereign endpoint: cdn.orzatty.com. Rather than re-hosting terabytes of packages, it acts as a smart proxy that caches aggressively at Cloudflare's edge, normalizes latency, shields user IPs from upstream CDNs, and extends upstream capabilities with features like ImageXR, GraphQL caching, and SRI computation.

Worker Implementation The entire CDN worker is 1,203 lines of JavaScript deployed as a single Cloudflare Worker (V8 isolate). Each request gets a fresh execution context with guaranteed CPU time limits, making the system inherently resistant to runaway requests and memory leaks.

2. Infrastructure Stack

ComponentTechnologyRole
ComputeCloudflare Workers (V8)Request routing, proxy logic, cache control
Object StorageCloudflare R2Proprietary assets, ImageXR source images
DatabaseCloudflare D1 (SQLite)Package metadata, analytics aggregates
Image ProcessingCloudflare Image ResizingOn-the-fly resize, WebP/AVIF conversion
API BackendVercel (Node.js)Complex operations at /api/v2/pulse
Cache LayerCloudflare Cache API + TagsEdge caching with selective invalidation
WAFCloudflare WAF RulesHotlink protection, bot mitigation

3. 15+ Proxy Routes

The pattern cdn.orzatty.com/{route}/... dispatches to the appropriate upstream CDN. Each route has a dedicated proxy function with custom headers and cache strategy:

/npm/{pkg}@{ver}/
→ jsDelivr npm mirror
/gh/{user}/{repo}/
→ jsDelivr GitHub CDN
/ipfs/{cid}
→ Web3.storage gateway
/cdnjs/{lib}/{ver}/
→ cdnjs.cloudflare.com
/tw/{ver}/
→ Tailwind CSS CDN
/esm/{module}
→ esm.sh (ESM builds)
/jsr/{scope}/{pkg}
→ jsr.io (Deno registry)
/fonts/css2
→ Google Fonts CSS (rewritten)
/gstatic/
→ Google Fonts binary assets
/iconify/{set}/
→ Iconify API + CDN
/unpkg/{pkg}/
→ unpkg.com
/wp/{site}/wp-json/
→ WordPress.com JSON API
/imagexr/
→ R2 + Cloudflare Resizing
/raw-storage/
→ R2 direct object serve
/api/v2/pulse
→ orzattycloud-api.vercel.app
/api/sri/
→ Internal SRI computation

Custom Response Headers

Every proxied response is enriched with Orzatty headers regardless of upstream origin:

X-Powered-By: OrzattyCloud CDN v1.0
X-Request-ID: <uuid-per-request>
Access-Control-Allow-Origin: *
CDN-Cache-Control: public, max-age=<ttl>
Vary: Accept-Encoding

4. Cache Strategy

Cache TTL is calibrated to content immutability. Versioned assets (npm, jsDelivr) get maximum caching; live content gets minimal:

RouteTTLRationale
/npm/@{ver}/, /gh/{sha}/1 YearContent-addressed — immutable by definition
/gstatic/fonts/1 YearGoogle font files never change at a given URL
/iconify/{set}/7 DaysIcon sets are versioned but not strictly immutable
/fonts/css224 HoursFont CSS may change for variable fonts
/unpkg/ (latest), /api/packages/search5 MinutesLatest tag may update; searches must stay fresh
/api/graphql (POST)60 SecondsBalance freshness vs. GraphQL origin load
/raw-storage/*.m3u85 SecondsHLS live playlist — must not be stale
/raw-storage/*.ts1 HourHLS segments are immutable once written

Cache Tag Architecture

Tags enable surgical invalidation — purging only specific packages without touching the entire cache:

Cache-Tag: pkg-{packageName}, all-assets, meta-{packageName}, cdnjs-{libName}

5. ImageXR: On-the-Fly Image Processing

ImageXR dynamically transforms images stored in R2 using Cloudflare's native Image Resizing — no separate processing server required:

// Request: serve from R2, resize to 800px wide, convert to WebP
GET /imagexr/hero-banner.jpg?w=800&format=webp&quality=85

// Processing (inside the Worker):
// 1. Parse params → width:800, format:webp, quality:85
// 2. Fetch source from R2: env.orzatty_cdn_storage.get('hero-banner.jpg')
// 3. Apply Cloudflare Image Resizing via cf.image:{width,format,quality}
// 4. Return: Content-Type:image/webp | Cache-Control:public,max-age=86400

Supported transforms: ?w= width, ?h= height, ?format=webp|avif|jpeg|png, ?quality=1-100. First request ~50–200ms; subsequent requests from edge cache <10ms.

6. GraphQL POST Cache

Standard HTTP caches cannot cache POST requests. OrzattyCloud CDN implements a custom strategy: a SHA-256 hash of URL + request body is used as the edge cache key, enabling cache hits for any identical GraphQL query:

const cacheKey = `${request.url}::${await sha256(body)}`;

// On MISS → fetch origin, store with:
//   Cache-Control: public, max-age=60
//   X-Orzatty-Graph-Cache: MISS

// On HIT → serve from edge with:
//   X-Orzatty-Graph-Cache: HIT

7. SRI Computation Engine

Subresource Integrity allows browsers to verify CDN assets have not been tampered with. The /api/sri/ endpoint computes SHA-256 hashes on demand:

GET /api/sri/?resource=npm/jquery@3.7.1/dist/jquery.min.js

{
  "url": "https://cdn.orzatty.com/npm/jquery@3.7.1/dist/jquery.min.js",
  "integrity": "sha256-gnr1Efy+vZOhEHCg/SHPPZjEjW//+dIb/2Wn/1cjsvo=",
  "cached": false
}

// Usage in HTML:
<script src="https://cdn.orzatty.com/npm/jquery@3.7.1/dist/jquery.min.js"
        integrity="sha256-gnr1Efy+..."
        crossorigin="anonymous"></script>

8. Google Fonts Privacy Proxy

GDPR concern: requesting fonts directly from fonts.googleapis.com exposes user IPs to Google. OrzattyCloud CDN proxies both the CSS and the binary font files, rewriting all URLs in the CSS to point to cdn.orzatty.com/gstatic/... — the browser never makes a direct request to Google.

// Google's CSS references:
src: url(https://fonts.gstatic.com/s/inter/v12/UcCO3FwrK3iLT...woff2)

// OrzattyCloud CDN rewrites to:
src: url(https://cdn.orzatty.com/gstatic/s/inter/v12/UcCO3FwrK3iLT...woff2)

9. R2 Storage Backend

Cloudflare R2 is S3-compatible, egress-free, and accessible from Workers with sub-millisecond latency. The serveRawR2() function implements HTTP 304 conditional requests, avoiding retransmitting unchanged files:

const object = await env.orzatty_cdn_storage.get(key, {
    onlyIf: {
        etagMatches: request.headers.get('If-None-Match'),
    }
});

// If object.body === null → return 304 (not modified)
// Otherwise → stream body with ETag + Cache-Control

10. Security Model

© 2026 ORZ Holdings — OrzattyCloud Infrastructure. research@orzatty.org