From reading the docs at http://wiki.nginx.org/HttpProxyModule I find mentions of using the proxy_cache_*
directives to achieve similar functionality, although not exactly what you're after. The docs state that:
Upstream cache-related directives have priority over proxy_cache_valid value,
in particular the order is:
X-Accel-Expires
Expires/Cache-Control
proxy_cache_valid
So it seems that setting the Expires
header at the proxy level may not be supported, or recommended.
I have a feeling that you should be setting the Expires
header up-stream. This can be done in Go (slightly hackishly, I'm sure there's a nicer way to fix the time-zone in the string) by setting the header on the http.ResponseWriter in your http handler function:
w.Header().Set("Expires", strings.Replace(time.Now().AddDate(0, 0, 30).Format(time.RFC1123), "UTC", "GMT", 1))
As previously stated, this replaces UTC
with GMT
in the output string. I'm not sure if it's necessary, but I've noticed this seems to be the common form in any HTTP headers I've inspected. I haven't looked up the spec to see if UTC
would be equally accepted by browsers, but I don't see why not.
Sorry it's not really an Nginx answer, hopefully it helps!