PlugImageProcessing.Middlewares.CacheHeaders (plug_image_processing v0.9.1)
View SourceMiddleware for setting HTTP cache control headers on image responses.
This middleware manages client and CDN caching behavior for processed images, helping to reduce server load and improve performance by leveraging browser and CDN caches.
Configuration
Set http_cache_ttl in your config to enable this middleware:
# Cache images for 1 hour (3600 seconds)
plug PlugImageProcessing.Web, http_cache_ttl: 3600
# Disable caching
plug PlugImageProcessing.Web, http_cache_ttl: 0Cache Behavior
- TTL > 0: Sets public caching with the specified max-age
- TTL = 0: Disables caching with no-cache, no-store directives
- Includes s-maxage for shared cache (CDN) control
- Sets no-transform to prevent CDN image modifications