File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22PORT = 3000
33
44# Cache settings
5- CACHE_MODE = disk # Cache mode: "disk" | "memory" | "none" (default: disk)
6- CACHE_DIR = ./cache # Directory for disk cache (only used when CACHE_MODE=disk)
5+ # Cache modes:
6+ # disk - Persist to disk only (survives restarts)
7+ # memory - In-memory only (fastest, lost on restart)
8+ # hybrid - Memory (L1) + Disk (L2) for speed and persistence
9+ # none - No caching
10+ CACHE_MODE = disk
11+ CACHE_DIR = ./cache # Directory for disk cache (disk/hybrid modes)
712CACHE_TTL = 86400 # Cache TTL in seconds (default: 24 hours)
813MAX_CACHE_SIZE = 1073741824 # Max cache size in bytes (default: 1GB, disk mode only)
9- MAX_MEMORY_CACHE_ITEMS = 1000 # Max items in memory cache (default: 1000, memory mode only )
14+ MAX_MEMORY_CACHE_ITEMS = 1000 # Max items in memory cache (memory/hybrid modes )
1015BROWSER_CACHE_TTL = 31536000 # Browser cache TTL in seconds (default: 1 year)
1116
1217# Security
13- ALLOWED_DOMAINS = # Comma-separated list of allowed domains (empty = allow all)
18+ ALLOWED_DOMAINS = # Comma-separated source image domains (empty = allow all)
19+ # Example: example.com,cdn.example.com
20+ ALLOWED_ORIGINS = # Comma-separated CORS origins (empty = allow all)
21+ # Example: https://example.com,https://app.example.com
1422MAX_IMAGE_SIZE = 10485760 # Max image size in bytes (default: 10MB)
1523REQUEST_TIMEOUT = 30000 # Request timeout in ms (default: 30s)
1624
Original file line number Diff line number Diff line change @@ -250,6 +250,35 @@ BROWSER_CACHE_TTL=31536000 # 1 year
250250TEMPLATES_DIR=./templates
251251```
252252
253+ ### Cache Modes
254+
255+ | Mode | Description |
256+ | -------- | --------------------------------------------------------------------------- |
257+ | ` disk ` | Persist to disk only. Survives restarts but slower reads. |
258+ | ` memory ` | In-memory LRU cache. Fastest but lost on restart. |
259+ | ` hybrid ` | Memory (L1) + Disk (L2). Fast reads with persistence. Best for production. |
260+ | ` none ` | No caching. Every request processes the image fresh. |
261+
262+ ### Security Settings
263+
264+ | Variable | Description |
265+ | ----------------- | ----------------------------------------------------------------------------------------------------- |
266+ | ` ALLOWED_DOMAINS ` | Restricts which domains can be used as image sources. Supports subdomains (e.g., ` example.com ` allows ` cdn.example.com ` ). |
267+ | ` ALLOWED_ORIGINS ` | Restricts which origins can make CORS requests. Use full URLs (e.g., ` https://example.com ` ). |
268+
269+ ** Example configuration for production:**
270+
271+ ``` bash
272+ # Only allow fetching images from your domain
273+ ALLOWED_DOMAINS=example.com
274+
275+ # Only allow your frontend to make requests
276+ ALLOWED_ORIGINS=https://example.com,https://app.example.com
277+
278+ # Use hybrid cache for best performance
279+ CACHE_MODE=hybrid
280+ ```
281+
253282## Custom Templates
254283
255284Create JSON template files in the ` templates/ ` directory:
You can’t perform that action at this time.
0 commit comments