TransWikia.com

nginx remove header from upstream

Server Fault Asked on December 30, 2021

I have nginx with upstream.

The upstream sets headers:

Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache

Because I want this page to be cached, in nginx I have following conf:

    location ~* ^.+.(html)$ {
            proxy_pass      http://websitefarm.php73;

            add_header      Pragma          "";
            add_header      x-pragma        "OK";
            expires         1d;
    }

it successfully remove Expires and Cache-Control, but Pragma stays.

note my test header "x-pragma" is set. so definitely conf "works"

expires: Sat, 25 Jul 2020 12:13:04 GMT
cache-control: max-age=86400
pragma: no-cache
x-pragma: OK

if i try set "Pragma" to something else, it works, but "" not seems to work.

2 Answers

This is a PHP configuration issue. You have set session.cache_limiter to nocache, either by leaving it at its default or by setting it explicitly in code, or both.

If the pages of interest are indeed cacheable, and are not for logged-in users, you need to have a chat with the application's developer about the inappropriate use of sessions.

Answered by Michael Hampton on December 30, 2021

Seems like this can be removed only with proxy_hide_header directive

Following config works:

    location ~* ^.+.(html)$ {
            proxy_pass              http://websitefarm.php73;
            proxy_hide_header       Pragma;
            expires                 1d;
    }

Answered by Nick on December 30, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP