OGify includes a built-in caching system to improve performance by reducing redundant network requests for fonts and emojis. You can configure caching when creating a renderer.
Configuration
Memory Cache
Filesystem Cache
Fast in-memory cache with LRU eviction (default) import { createRenderer } from '@ogify/core' ;
const renderer = createRenderer ({
templates: { /* ... */ },
cache: {
type: 'memory' ,
ttl: 3600000 , // 1 hour (optional)
max: 100 // Max items (optional)
}
});
Persistent cache stored on disk import { createRenderer } from '@ogify/core' ;
const renderer = createRenderer ({
templates: { /* ... */ },
cache: {
type: 'filesystem' ,
dir: '.cache/ogify' , // Cache directory
ttl: 3600000 , // 1 hour (optional)
max: 100 // Max items (optional)
}
});
What is Cached?
Fonts downloaded from Google Fonts or other URLs are cached to avoid
repeated network requests.
Emoji images from providers like Twemoji, Fluent, etc. are cached for faster
rendering.
(Optional) Depending on implementation, images with identical parameters may
be served from cache.
Disabling Cache
Not recommended for production environments
To disable caching completely:
const renderer = createRenderer ({
// ...
cache: false ,
});