Changing upstream response headers, before nginx caching decisions

Gryzli Bugbear gryzli.the.bugbear at gmail.com
Fri Jun 23 12:12:24 UTC 2017


Hi Maxim,

Thanks for your prompt answer !

That's exactly what I'm using currently, but was thinking if there is 
some more elegant/performance-effective way of doing this thing.


Regards


On 06/23/2017 03:09 PM, Maxim Dounin wrote:
> Hello!
>
> On Fri, Jun 23, 2017 at 02:31:37PM +0300, Gryzli Bugbear wrote:
>
>> I have the following working scheme:
>>
>> Client --> Nginx [caching] --> Apache [backend]
>>
>>
>> Sometime the backend returns headers, which I want to modify before
>> nginx caching engine decides how to treat them. One such example is when
>> backend returns Vary:  header.
>>
>>
>> I want to achieve the following:
>>
>>
>> [Apache backend returns Vary: User-Agent, Header2] --> [Nginx Modifies
>> "Vary:" and removes User-Agent] --> [Nginx caching sees only 'Vary:
>> Header2' (without User-Agent)] --> The final result is that Nginx cache
>> wont take 'User-Agent' into vary considerations. (no cache object per UA).
>>
>> That's just an example. I would like to do such modification with other
>> headers also (for example Cache-Control).
>>
>> Currently I'm already using Nginx Lua integration, but there is no hook
>> point before the caching engine.
>>
>>
>> Would be happy for any suggestions about achieving this scenario.
> As of now, the only solution would be to use intemediate proxy
> (without caching) to modify headers returned by your backend.
>



More information about the nginx mailing list