Skip to content

Instantly share code, notes, and snippets.

View aakashlpin's full-sized avatar

Aakash Goel aakashlpin

View GitHub Profile
@aakashlpin
aakashlpin / swr.ts
Created December 21, 2022 07:19 — forked from wilsonpage/swr.ts
An implementation of stale-while-revalidate for Cloudflare Workers
export const CACHE_STALE_AT_HEADER = 'x-edge-cache-stale-at';
export const CACHE_STATUS_HEADER = 'x-edge-cache-status';
export const CACHE_CONTROL_HEADER = 'Cache-Control';
export const CLIENT_CACHE_CONTROL_HEADER = 'x-client-cache-control';
export const ORIGIN_CACHE_CONTROL_HEADER = 'x-edge-origin-cache-control';
enum CacheStatus {
HIT = 'HIT',
MISS = 'MISS',
REVALIDATING = 'REVALIDATING',