# yaml-language-server: $schema=https://json.schemastore.org/traefik-v3-file-provider.json http: routers: imaging-cache: rule: PathPrefix(`/imaging-cache`) middlewares: - imaging-cache # before the prefix is stripped: the cache key is the public URL - imaging-prefix service: imaging # Validation: the backend sends an `ETag` and answers `304` to `If-None-Match`. Here its responses are only # fresh for 2 seconds: after that, the cache asks it whether the stored image is still current imaging-validate: rule: PathPrefix(`/imaging-validate`) middlewares: - imaging-client # acts on the Cache-Control of clients: e2e/tests/request.hurl asks for stale responses - imaging-validate-headers # after the cache: for the cache, this header comes from the backend - imaging-prefix service: imaging # Errors stored too: here a missing source image (`404`) is stored like an image, for `defaultTtl` imaging-cache-errors: rule: PathPrefix(`/imaging-cache-errors`) middlewares: - imaging-cache-errors - imaging-prefix service: imaging imaging: rule: PathPrefix(`/imaging`) middlewares: - imaging-prefix service: imaging middlewares: # The backend serves ///plain/ imaging-prefix: stripPrefix: prefixes: - /imaging-cache-errors # first: /imaging-cache is its prefix - /imaging-cache - /imaging-validate - /imaging # last: the others start with it imaging-validate-headers: headers: customResponseHeaders: Cache-Control: "max-age=2" imaging-cache: plugin: traedis: redis: dsn: "redis://cache:6379/0" defaultTtl: 5m # 0 by default: imgproxy sends no Cache-Control with its errors, which statusCodes keeps out here imaging-client: plugin: traedis: redis: dsn: "redis://cache:6379/0" followClientCacheControl: true # off by default: request directives are advisory (RFC 9111 ยง5.2.1) imaging-cache-errors: plugin: traedis: redis: dsn: "redis://cache:6379/0" defaultTtl: 5m statusCodes: [ "200-399", 404 ] # the default, and 404 services: imaging: loadBalancer: servers: - url: "http://imaging:8080"