Welcome! Log In Create A New Profile

Advanced

Possible to modify response headers from a proxied request before the response is written do the cache? (modified headers should be written to disk)

Manuel
March 11, 2019 08:00PM
Hello,

nginx writes the rsponse from a proxy to disk. eg.
[...]
Server: nginx
Date: Mon, 11 Mar 2019 23:23:28 GMT
Content-Type: image/png
Content-Length: 45360
Connection: close
Expect-CT: max-age=0, report-uri="
https://openstreetmap.report-uri.com/r/d/ct/reportOnly"
ETag: "314b65190a8968893c6c400f29b13369"
Cache-Control: max-age=126195
Expires: Wed, 13 Mar 2019 10:26:43 GMT
Access-Control-Allow-Origin: *
X-Cache: MISS from trogdor.openstreetmap.org
X-Cache-Lookup: HIT from trogdor.openstreetmap.org:3128
Via: 1.1 trogdor.openstreetmap.org:3128 (squid/2.7.STABLE9)
Set-Cookie: qos_token=031042; Max-Age=3600; Domain=openstreetmap.org; Path=/
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
[...]

is it possible to modify the Cache-Control and Expires header before the
response is written to disk?

The config:

location /tiles/ {
proxy_http_version 1.1;
proxy_ignore_headers "Cache-Control" "Expires" "Set-Cookie";
proxy_cache_valid any 30d;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X_FORWARDED_PROTO https;
proxy_set_header Host $proxy_host;
proxy_ssl_server_name on;
proxy_ssl_name $proxy_host;

proxy_ssl_certificate /etc/nginx/cert.pem;
proxy_ssl_certificate_key /etc/nginx/key.pem;

expires 30d;
proxy_cache_lock on;
proxy_cache_valid 200 302 30d;
proxy_cache_valid 404 1m;
proxy_cache_key "$request_uri";
proxy_redirect off;
proxy_cache_use_stale error timeout http_500 http_502
http_503 http_504;
add_header X-Cache-Status $upstream_cache_status;

# add_header Cache-Control public;
add_header Last-Modified "";
add_header ETag "";

proxy_cache tiles;
proxy_pass https://openstreetmap_backend/;
}

The problem is: the cached tiles on disk do not have "Cache-Control:
max-age=2592000" but "Cache-Control: max-age=126195" regardless of setting
proxy_ignore_headers "Cache-Control".
I assumed that setting proxy_ignore_headers "Cache-Control"; and "expires
30d;" will remove the header from the response and write the corresponding
"Cache-Control" and "Expires" with the 30d.


Or do I have to do this:

browser ->
nginx, caches and if necessary requests new tile via ->
nginx, sets expires: 30d; calls tileserver

Kind regards,
Manuel
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Possible to modify response headers from a proxied request before the response is written do the cache? (modified headers should be written to disk)

Manuel March 11, 2019 08:00PM

Re: Possible to modify response headers from a proxied request before the response is written do the cache? (modified headers should be written to disk)

Maxim Dounin March 12, 2019 08:44AM

Re: Possible to modify response headers from a proxied request before the response is written do the cache? (modified headers should be written to disk)

Manuel March 12, 2019 04:44PM

Re: Possible to modify response headers from a proxied request before the response is written do the cache? (modified headers should be written to disk)

Maxim Dounin March 12, 2019 10:12PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 62
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready