Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.8k views
in Technique[技术] by (71.8m points)

caching - Disable cache control in nginx ingress controler for certain response

I have this ingress configuration but all html and json reponse pages dont contain the added header:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: {{ $app }}-ingress
  labels:
    app: {{ $app }} 
    chart: chart-{{ $app }}
    app.kubernetes.io/managed-by: Helm
  annotations:
    meta.helm.sh/release-name: {{ $app }}
    meta.helm.sh/release-namespace: {{ .Release.Namespace }}
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/proxy-body-size: "{{ $proxy_body_size }}"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "{{ $proxy_read_timeout }}"
    nginx.ingress.kubernetes.io/proxy-connect-timeout: "{{ $proxy_connect_timeout }}"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "{{ $proxy_send_timeout }}"
    nginx.ingress.kubernetes.io/proxy-buffer-size: "{{ $proxy_buffer_size }}"
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/configuration-snippet : |
        if ($request_uri ~* .(html|json)) {
           add_header Cache-Control "no-cache,no-store";
        }
spec:
  tls:
    - hosts:
        - {{ $alias }}
  rules:
    - host: {{ $alias }}
      http:
        paths:
          - path: /(.*)
            backend:
              serviceName: {{ $app }}-service
              servicePort: http-back

I want to disable cache control only for html and json content response. When I remove the if ($request_uri ~* .(html|json)) condition, all responses have the added header. So this means that the condition in the configuration-snippet is not correct.

Can you help please?

question from:https://stackoverflow.com/questions/65907441/disable-cache-control-in-nginx-ingress-controler-for-certain-response

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...