Skip to main content

Powered by Cloudflare

Imperial uses Cloudflare’s global CDN network to deliver your media with industry-leading performance. With 310+ data centers in 120+ countries, your content is served from the location closest to your users.

Network Statistics

310+ Data Centers

Spanning every continent

120+ Countries

Global presence

<50ms Latency

95th percentile worldwide

How CDN Caching Works

When someone requests your image or video, here’s what happens:
1

User Makes Request

A user in Tokyo requests your image: https://cdn.imperial.gay/uploads/user-id/cat.jpg
2

Cloudflare Routing

The request is automatically routed to the nearest Cloudflare data center (Tokyo)
3

Cache Check

Cloudflare checks if the file is already cached at that location
4

Cache Hit (Fast Path)

If cached → File is delivered instantly (~10-30ms)
5

Cache Miss (First Time)

If not cached → Fetch from R2 storage → Cache at edge → Deliver to user
6

Subsequent Requests

Future requests from that region are served from cache instantly

Performance Comparison

Traditional vs CDN Delivery

User in Sydney requests file from US server:
Sydney → USA (Origin Server)
├─ DNS Resolution: ~50ms
├─ TCP Handshake: ~200ms  
├─ TLS Handshake: ~200ms
├─ HTTP Request: ~200ms
└─ Data Transfer: ~500ms (for 1MB file)

Total: ~1,150ms (1.15 seconds) 🐌
That’s 23x faster! CDN delivery can reduce load times from seconds to milliseconds.

Cache Strategy

Imperial’s CDN caching is optimized for media delivery:

Cache Rules

  • Cache Duration: 30 days
  • Cache Key: Full URL
  • Cache Control: public, max-age=2592000, immutable
  • Optimization: Served from edge with Cloudflare Polish (auto-optimization)
  • Cache Duration: 30 days
  • Cache Key: Full URL
  • Streaming: Range request support for smooth playback
  • Optimization: Adaptive bitrate delivery when available
  • Cache Duration: 90 days (rarely change)
  • Format: Optimized JPEG
  • Purpose: Fast gallery loading

Global Performance

Average Latency by Region

RegionFirst LoadCached Load
North America100-150ms20-40ms
Europe80-120ms15-35ms
Asia90-140ms18-38ms
South America120-180ms25-45ms
Oceania110-160ms22-42ms
Africa130-200ms28-50ms
These are 95th percentile numbers. Most requests are even faster!

Advanced Features

HTTP/3 Support

Imperial supports HTTP/3 (QUIC protocol) for even faster connections:
HTTP/1.1: 6-8 round trips to establish connection
HTTP/2:   3-4 round trips
HTTP/3:   1-2 round trips ⚡
Benefits:
  • Faster connection establishment
  • Better performance on mobile networks
  • Improved handling of packet loss
  • Multiplexed streams

Brotli Compression

Text-based responses (JSON, HTML) are compressed with Brotli:
  • 20-30% smaller than Gzip
  • Faster decompression on modern devices
  • Automatically enabled for all API responses

Early Hints (103 Status Code)

Cloudflare sends early hints to browsers while the origin processes requests, allowing browsers to start loading resources sooner.

Cache Warming

Popular content automatically stays cached across the global network:
1

Initial Upload

File is stored in R2 (origin storage)
2

First Request

File is cached at the requesting edge location
3

Popularity Detection

If file receives multiple requests, Cloudflare proactively caches it at more locations
4

Global Distribution

Viral content automatically spreads across all 310+ edge locations

Smart Routing

Cloudflare’s Argo Smart Routing optimizes the path between edge and origin:
Traditional Routing:
User → Edge → Public Internet → Origin
        └─ Takes the "default" internet path
        └─ May encounter congestion

Argo Smart Routing:
User → Edge → Cloudflare Private Network → Origin
        └─ Uses faster, less congested Cloudflare backbone
        └─ 30% faster on average

DDoS Protection

Built-in protection against attacks that could slow down your content:

Layer 3/4 Protection

Mitigates network-layer attacks automatically

Layer 7 Protection

Filters malicious application-layer requests

Always Online

Serves cached content even if origin is down

Rate Limiting

Prevents abuse and ensures fair usage

Mobile Optimization

Special optimizations for mobile devices:

Connection Quality Adaptation

Cloudflare detects connection quality and adapts delivery:
  • Fast WiFi/5G: Full quality, parallel connections
  • 4G: Moderate optimization, pipelined requests
  • 3G/Slow: Aggressive compression, sequential loads

Image Optimization

For supported devices, images are automatically optimized:
  • Format conversion: Serve WebP/AVIF to supporting browsers
  • Size optimization: Reduce file size without quality loss
  • Lazy loading hints: Suggest browser-level lazy loading

Monitoring & Analytics

Track your CDN performance in real-time:
# Check cache status via headers
curl -I https://cdn.imperial.gay/uploads/user-id/image.jpg

# Response headers:
CF-Cache-Status: HIT
CF-Ray: 8e5a4b3c2d1e0f1a-LAX
Age: 3600
Cache-Control: public, max-age=2592000

Cache Status Values

StatusMeaning
HITServed from cache (fast!)
MISSFirst request, fetched from origin
EXPIREDCache expired, revalidating
STALEServing stale while revalidating
BYPASSCache bypassed (e.g., query parameters)

Best Practices

Consistent URLs: Use the same URL for each file. Changing URLs creates new cache entries and wastes cache space.
Query Parameters: Avoid unnecessary query parameters. image.jpg?v=1 and image.jpg?v=2 are cached separately.
File Names: Use meaningful, permanent filenames. Imperial automatically generates stable URLs.

Technical Deep Dive

Anycast Network

Cloudflare uses Anycast routing where all edge locations share the same IP addresses:
Traditional (Unicast):
├─ us-east.example.com → 1.2.3.4
├─ eu-west.example.com → 5.6.7.8
└─ asia.example.com → 9.10.11.12

Imperial/Cloudflare (Anycast):
└─ cdn.imperial.gay → 104.18.x.x
   ├─ Routes to nearest data center automatically
   └─ No manual geo-routing needed

Cache Hierarchy

User Request

Edge Cache (Tier 1) - 310+ locations
    ↓ (cache miss)
Regional Cache (Tier 2) - ~50 locations
    ↓ (cache miss)
Origin (R2 Storage)
This multi-tier approach means even cache misses are fast!

Get Started

Experience the speed difference:

Upload Your First File

See how fast global delivery can be