Refactor: Update README to reflect store-as-is approach

This commit is contained in:
2026-02-13 15:51:12 -08:00
parent 709737fce7
commit cd1e4576f4

View File

@@ -17,8 +17,8 @@ That's it. The image is searched, cached, and served.
## How It Works ## How It Works
1. A request hits `direct-img.link/<query>` 1. A request hits `direct-img.link/<query>`
2. If cached (within 30 days) → serves the image instantly from edge 2. If cached (within 30 days) → serves the image instantly from R2
3. If not cached → searches via Brave Image Search API → compresses to WebP → caches in R2 → serves 3. If not cached → searches via Brave Image Search API → stores in R2 → serves
## URL Format ## URL Format
@@ -63,6 +63,7 @@ as the image URL. Use + to separate words. Example: ![orange cat](https://direct
- Images are cached for **30 days** - Images are cached for **30 days**
- After expiry, the next request triggers a fresh search - After expiry, the next request triggers a fresh search
- Images are stored in their original format as fetched from source
## Support ## Support
@@ -89,8 +90,8 @@ Create in your Cloudflare dashboard:
| Resource | Name | Purpose | | Resource | Name | Purpose |
|---|---|---| |---|---|---|
| R2 Bucket | `direct-img-store` | Stores compressed WebP images | | R2 Bucket | `direct-img-store` | Stores cached images |
| KV Namespace | `DIRECT_IMG_CACHE` | Cache existence + timestamp | | KV Namespace | `DIRECT_IMG_CACHE` | Cache existence + content type + timestamp |
| KV Namespace | `DIRECT_IMG_RATE` | Per-IP daily search counter | | KV Namespace | `DIRECT_IMG_RATE` | Per-IP daily search counter |
### 3. Pages Bindings ### 3. Pages Bindings
@@ -128,11 +129,11 @@ Fork this repo, connect to Cloudflare Pages, deploy.
### R2: `direct-img-store` ### R2: `direct-img-store`
**Key:** `<sha256-of-normalized-query>.webp` — derived from query, no lookup needed. **Key:** `<sha256-of-normalized-query>` — derived from query, no lookup needed. Stored with original content type from source.
### KV: `DIRECT_IMG_CACHE` ### KV: `DIRECT_IMG_CACHE`
**Key:** normalized query (lowercase, trimmed) → **Value:** `{"t":1719000000}`**TTL:** 30 days **Key:** normalized query (lowercase, trimmed) → **Value:** `{"t":1719000000,"ct":"image/jpeg"}`**TTL:** 30 days
### KV: `DIRECT_IMG_RATE` ### KV: `DIRECT_IMG_RATE`