Skip to content

Giphy/cloudflare-cdn-config-ref-implementation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Giphy Media CDN Revalidation — Usage Example & Reference Documentation

This repository provides a complete reference implementation of this architecture:

Cloudflare Worker (Serverless)

A distributed, serverless approach using Cloudflare Workers.

  • Pros: Global distribution by default, zero server management, sub-millisecond setup.
  • Tech: JavaScript, Cloudflare KV/Cache API, Wrangler.

Implementation Overview

Regardless of the implementation, the flow remains the same:

┌───────────┐       ┌─────────────────┐       ┌──────────────────┐       ┌──────────────────┐
│  Client   │──────▶│   Cloudflare    │──────▶│   Revalidation   │──────▶│  Origin API      │
│  Browser  │◀──────│   CDN Edge      │◀──────│   Proxy/Worker   │◀──────│  media.giphy.com │
└───────────┘       └─────────────────┘       └──────────────────┘       └──────────────────┘
                         │                         │
                    Caches based on           In-memory or KV
                    Cache-Control             cache + ETag
                    headers from              revalidation
                    revalidation layer        logic

Quick Start

Debugging & Observability

Both solutions inject X-Debug-* headers to provide insight into the caching flow:

  • X-Debug-Cache: HIT, MISS, STALE, REVALIDATED, PURGED.
  • X-Debug-Origin: The actual status code returned by the upstream origin.
  • X-Debug-ETag: The ETag value used for the revalidation check.

License

This is a reference implementation. See repository license for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors