Set Expires Header only if upstream has not already set an Expires

Francis Daly francis at daoine.org
Wed Nov 22 23:26:33 UTC 2017


On Wed, Nov 22, 2017 at 10:41:49AM +0100, Thomas Glanzmann wrote:

Hi there,

> I would like to add an Expires Header only to upstream content that has
> not already set an Expires header. Is there an easy way to do that with
> nginx?

http://nginx.org/r/expires has an example of setting a value based on
$sent_http_content_type.

You can set a value based on $upstream_http_expires --

{ default off; "" 7d; }

in the appropriate "map" should set your Expires time to 7 days from now
if there is not an Expires: header from the upstream.

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list