Skip to content

A fast, modern, and cache-friendly Gravatar CDN proxy — built with Cloudflare Workers and Hono.

License

Notifications You must be signed in to change notification settings

ZL-Asica/Gravatar-Worker

Repository files navigation

Gravatar Worker

A fast, modern, and cache-friendly Gravatar CDN proxy — built with Cloudflare Workers and Hono.

GitHub License Latest Release

Node.js pnpm Version | Hono Vite Cloudflare Worker

Supports:

  • MD5 / SHA-256 hash or raw email lookups
  • Smart caching (Edge + Browser)
  • Auto image format conversion to AVIF or WebP based on Accept header

🌐 Endpoints

🔹 GET /avatar/me

Fetches the maintainer's Gravatar avatar with no params needed.

Example:

GET /avatar/me

🔹 GET /avatar/:hash

Fetches the Gravatar avatar via precomputed MD5 or SHA-256 hash.

Example:

GET /avatar/205e460b479e2e5b48aec07710c08d50?s=128

🔹 GET /avatar?email=<email>

Fetches the avatar by raw email (safely hashed server-side).

Example:

GET /[email protected]&size=256

⚙️ Query Parameters

Param Description Default
s or size Image size in pixels (square, e.g. 128x128) 200
d or default Default fall back option (e.g. a URL, or 404) 404

🎨 Format Negotiation

Automatically returns the most optimized format:

  • image/avif (if supported)
  • image/webp (fallback)
  • Original JPEG (fallback fallback 🙃)

Based on the browser’s Accept header:

Accept: image/avif,image/webp,image/*,*/*

📦 Caching Strategy

Response Browser TTL Edge TTL Notes
200 OK 1 day 30 days stale-while-revalidate enabled
404 5 minutes 1 hour Allows retry for new users

Built-in Cloudflare CDN handles global delivery and bandwidth optimization.

🧪 Tech Stack

  • Cloudflare Workers – fast and global by design
  • Hono – lightweight routing framework (also Hono JSX for API doc)
  • @jsquash – AVIF/WebP encoding via WASM
  • TypeScript – strong typing, strict mode
  • Pure CSS – custom theme 💮

🧾 License

This project is licensed under the MIT License.

About

A fast, modern, and cache-friendly Gravatar CDN proxy — built with Cloudflare Workers and Hono.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published