WDCACHE CDN

WDCACHE CDN
WDCACHE CDN
Dashboard Files Queue Docs Settings Text Morph
Light Logout

API Documentation

Add file to CDN

POST /api/cdn · Header: X-Api-Key · JSON or multipart/form-data
src — source URL (for remote files)
file — uploaded file (for local files, multipart)
type — required (image, video, audio, file)
params — processing parameters. Empty or omitted = save original
ttl — seconds. 0 or omitted = permanent
project — optional label for grouping
Either src or file required. Uploaded files don't support TTL refresh — no source to re-fetch after expiry.
Response: { "url": "/cdn/encrypted_hash" }

Params by type

Image
w width · h height · q quality 1–100 · mode fit | crop → converts to WebP
Video
codec libx265 | libx264 | libvpx-vp9 · crf 18–40 · preset ultrafast–slow · resolution 1280:-2 · audio_bitrate 96k → converts to MP4
Audio
codec libmp3lame | aac | libopus · bitrate 64k–320k → converts to MP3
File
No params. Always saved as original. PDF, fonts, JSON, CSV, etc.

How it works

Generate → creates encrypted URL + adds task to queue
Worker → fetches source, processes, saves to cache (runs every minute)
GET /cdn/... → serves from cache. If not ready: 202 with status, error and original src
TTL refresh → every request to the file resets the expiry timer. File stays alive as long as it's being accessed
TTL expiry → if no one accesses the file for the TTL duration, cleanup cron deletes it. For URL sources — next request re-fetches and re-processes automatically. For uploaded files — deleted permanently (no source to re-fetch)
TTL=0 → permanent, never deleted

Responses

200 — file served from cache
202 — processing: { "status": "pending|processing|failed", "error": "...", "src": "..." }
400 — bad request (missing type, src, bad format)
403 — bad API key or invalid encrypted URL
404 — record not found

Examples

Image — resize to 800px WebP
curl -X POST https://wdcache.ru/api/cdn \
  -H "X-Api-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"type":"image","src":"https://example.com/photo.jpg","params":{"w":800,"q":80}}'
Video — convert to 720p MP4
curl -X POST https://wdcache.ru/api/cdn \
  -H "X-Api-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"type":"video","src":"https://example.com/clip.mp4","params":{"crf":32,"resolution":"1280:-2"}}'
Audio — convert to 128k MP3
curl -X POST https://wdcache.ru/api/cdn \
  -H "X-Api-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"type":"audio","src":"https://example.com/track.wav","params":{"bitrate":"128k"}}'
File — store PDF as-is, permanent
curl -X POST https://wdcache.ru/api/cdn \
  -H "X-Api-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"type":"file","src":"https://example.com/doc.pdf","params":{}}'
Upload — file from device
curl -X POST https://wdcache.ru/api/cdn \
  -H "X-Api-Key: YOUR_KEY" \
  -F "file=@photo.jpg" \
  -F "type=image" \
  -F 'params={"w":800,"q":80}' \
  -F "project=my-project"

Limits

Max file size configured per type in Settings
Image limits (max width, height, quality) applied during conversion
Fetch timeout: image 30s, audio 60s, video 5min
Allowed file types restricted at storage level