问题
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?
来源:https://stackoverflow.com/questions/65907441/disable-cache-control-in-nginx-ingress-controler-for-certain-response