Invert the x-cache header logic

This commit is contained in:
2026-01-07 20:29:46 +01:00
parent 7198a70ec4
commit 7de4d74fbf
2 changed files with 12 additions and 11 deletions

View File

@@ -1,10 +1,12 @@
services:
nginx-cache-proxy:
# image: docker.site.quack-lab.dev/nginx-cache-proxy:latest
image: nginx:alpine
# image: nginx:alpine
image: docker.site.quack-lab.dev/nginx-cache-proxy:latest
ports:
- "3001:3001"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx-data:/etc/nginx/data
restart: unless-stopped
# - ./nginx.conf:/etc/nginx/nginx.conf:ro
- nginx-data:/etc/nginx/data
volumes:
nginx-data:

View File

@@ -32,14 +32,13 @@ http {
proxy_cache api_cache;
proxy_cache_valid 200 365d;
proxy_cache_bypass $http_x_cache_this_inverse;
proxy_no_cache $http_x_cache_this_inverse;
proxy_cache_bypass $http_x_cache_inverse;
proxy_no_cache $http_x_cache_inverse;
set $http_x_cache_this_inverse 1;
if ($http_x_cache_this) {
set $http_x_cache_this_inverse 0;
set $http_x_cache_inverse 1;
if ($http_x_cache) {
set $http_x_cache_inverse 0;
}
add_header X-Cache-Status $upstream_cache_status always;
}
}