Welcome! Log In Create A New Profile

Advanced

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
Hello!

On Tue, Mar 12, 2019 at 12:57:59AM +0100, Manuel wrote:

> 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?

No. Cache stores the original response as got from the upstream
server.

You can, however, return different headers to clients, using the
"proxy_hide_header", "add_header", and "expires" directives. In
case of Cache-Control and Expires, just "expires" as already
present in your configuration should be enough.

[...]

> 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.

Well, your assumption is not correct. The "proxy_ignore_headers"
directive controls if nginx itself will respect Cache-Control or
not when caching a response. And the "expires" directive controls
what will be returned to clients.

From practical point of view, however, these should be enough to
return correct responses to clients. What is stored in the cache
file is irrelevant.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
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: 183
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready