How can I cache HTTP responses from my services in Kubernetes?
I have a simple web service in my cluster and am wondering how I could cache static assets (static html, images, fonts, etc.) beyond relying on client caches.
My setup is very simple:
┌─────────────────┐ ┌─────────────┐ ┌─────────────────┐
│ │ │ │ │ │
│ ingress-nginx ├────► svc ├───► deployment │
│ │ │ │ │ │
└─────────────────┘ └─────────────┘ └─────────────────┘
Options I've considered:
- external CDN (e.g. Cloudflare)
- => ruled out due to data protection compliance rules
- Cloud provider's CDN (e.g. Cloudfront)
- => our cloud provider doesn't have such a service
- proxy_cache in the ingress-nginx-controller & ingress
- => seems… messy?
- a dedicated caching service (e.g. Varnish) between ingress-nginx and my service
- => is this a good idea?
- => are there more "cloud-native" choices than configuring my own Varnish deployment?
- a caching proxy in a sidecar (e.g. Varnish or nginx)
- => not ideal because cache pods have to scale in line with application pods
- caching in the application
- => I'd prefer keeping this concern out of the application
I'm curious: how are people solving this problem in their clusters?