On-disk cache for rendered OG PNGs.
Cache key = SHA-256 of (template_uuid, template_updated_at, canvas, binding_values). Two different posts with the same resolved values
share a single file; editing the template invalidates every dependent
cache entry automatically (the template's updated_at is part of the
key).
Files live under priv/static/og_cache/ so we can reuse the host's
static-file plug without registering a new endpoint. Filename pattern:
<16-hex hash>.pngThe full hash is 64 hex; we truncate to 16 (64 bits) which is collision-resistant for our scale (millions of templates × posts).
Summary
Functions
Clears every cached render — useful after upgrading the renderer.
Writes the PNG bytes to the cache file. Atomic: write to a tempfile in the same dir then rename, so a concurrent read never sees a partial file.
Functions
@spec clear() :: :ok
Clears every cached render — useful after upgrading the renderer.
Returns {cache_key, absolute_path}. The path may or may not exist —
call exists?/1 or read/1 to check.
Writes the PNG bytes to the cache file. Atomic: write to a tempfile in the same dir then rename, so a concurrent read never sees a partial file.