Search code examples
cachingnginxkubernetesetags

kubernetes nginx ingress controller / caching static assets


I have a problem about the images returned via the apps running behind the nginx ingress controller. They always returns 200 instead of an expected 304 once visited.

Digging around, i've found out about the ability to add specific blocks within the servers; so added the following under metadata > annotations :

 ingress.kubernetes.io/server-snippets: |
   location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
     expires 30d;
     add_header Pragma public;
     add_header Cache-Control "public";
   }

The problems persists, so still getting a permanent 200; "ssh'ing" into the nginx pod and doing a cat on the nginx.conf created, I don't see this block appearing anywhere

So am kind of lost about how to improve it. I'm using kube-lego, but did not found out if it could have an impact here


Solution

  • Support for server-snippets annotation was added in nginx-0.9.0-beta.16. Upgrade your ingress controller image to quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.9.0-beta.16