<p>I have a kubernetes cluster running in AWS and am trying to modify the Cache Controller headers via the kubernetes ingress as such:</p>

<pre><code>---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: example-ingress-lab-static
  namespace: lab
  annotations:
    ingress.kubernetes.io/rewrite-target: /$1
    ingress.kubernetes.io/enable-cors: "true"
    ingress.kubernetes.io/cors-allow-methods: GET, POST,PUT, OPTIONS, DELETE, HEAD, PATCH
    ingress.kubernetes.io/cors-allow-headers: &gt;-
      Accept-Charset, Accept-Encoding, Access-Control-Request-Headers, Access-Control-Request-Method, Authorization,
      Cache-Control, Connection, Content-Encoding, Content-Type, Content-Length, DNT, Date, Host, If-Modified-Since,
      Keep-Alive, Origin, Referer, Server, TokenIssueTime, Transfer-Encoding, User-Agent, Vary, X-CustomHeader, X-Requested-With,
      password, username, x-request-id, x-ratelimit-app, x-auth-id, x-auth-key, x-guest-token, X-HTTP-Method-Override,
      x-oesp-username, x-oesp-token, x-cus, x-dev, X-Client-Id, X-Device-Code, X-Language-Code, UserRole, x-session-id, x-entitlements-token
    ingress.kubernetes.io/configuration-snippet: |
      more_set_headers 'Access-Control-Allow-Origin:$origin';
    ingress.kubernetes.io/proxy-buffering: "on"
    ingress.kubernetes.io/proxy-buffer-size: "2048k"
    ingress.kubernetes.io/server-snippet: |
      chunked_transfer_encoding        off;

      location ((https|http):\/\/.*\/test-service\/images\/.*\/imageName.*) {
        more_set_headers 'Cache-Control: public, max-age=14400';
      }


spec:
  rules:
  - host: static-url-lab.lab.cdn.example.com
    http:
      paths:
      - path: /test-service/(.*)
        backend:
          serviceName: test-service
          servicePort: 80
</code></pre>

<p>However this does not seem to be working. When I curl a resource matching that pattern I get the default values back:</p>

<pre><code># Example curl - not exact
curl -v "https://static-url-lab.lab.cdn.example.com/test-service/intent/test/image_name" -o /dev/null 2&gt;&amp;1 grep -E "(Cache-Control: max|X-Cache)"   
</code></pre>

<pre><code>&lt; Cache-Control: max-age=172800, public

</code></pre>

<p>As far as I can tell the regex should be matching, but no change is taking place, what am I missing?</p>

thewooster
<p>Try something like this :</p>

<p>working for me</p>

<pre><code>annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/configuration-snippet: |
      if ($request_uri ~* \.(js|css|gif|jpe?g|png)) {
        expires 1M;
        add_header Cache-Control "public";
      }
    nginx.ingress.kubernetes.io/proxy-body-size: 50m
    nginx.ingress.kubernetes.io/proxy-read-timeout: "1800"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "1800"
</code></pre>
