Join Server Fault

By clicking “Sign up”, you agree to our terms of service and acknowledge you have read our privacy policy.

Sign up with Google

OR

Email

Password

Sign up

Already have an account? Log in

Skip to main content

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Loading…

Tour

Start here for a quick overview of the site

Help Center

Detailed answers to any questions you might have

Meta

Discuss the workings and policies of this site

About Us

Learn more about Stack Overflow the company, and our products

current community

Server Fault

help
chat

Meta Server Fault

your communities

Sign up or log in to customize your list.

more stack exchange communities

company blog

Log in

Sign up

Home

Questions

Tags

Users

Jobs

Companies

Unanswered

Teams

Now available on Stack Overflow for Teams! AI features where you work: search, IDE, and chat.

Learn more
Explore Teams

Teams

Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Explore Teams

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

nginx remove header from upstream

Ask Question

Asked
4 years, 1 month ago

Modified
4 years, 1 month ago

Viewed
9k times

This question shows research effort; it is useful and clear

3

Save this question.

Show activity on this post.

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.

nginx

http-headers

Share

Share a link to this question

Copy linkCC BY-SA 4.0

Improve this question

Follow

Follow this question to receive notifications

asked Jul 24, 2020 at 12:21

NickNick

88222 gold badges1616 silver badges4343 bronze badges

Add a comment
|

2 Answers
2

Sorted by:

Reset to default

Highest score (default)

Date modified (newest first)

Date created (oldest first)

This answer is useful

2

Save this answer.

Show activity on this post.

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;
}

Share

Share a link to this answer

Copy linkCC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

answered Jul 24, 2020 at 12:37

NickNick

88222 gold badges1616 silver badges4343 bronze badges

1

This works fine with Nginx + Jenkins setup

– HamTheAstroChimp

Commented
Dec 24, 2021 at 12:28

Add a comment
|

This answer is useful

2

Save this answer.

Show activity on this post.

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.

Share

Share a link to this answer

Copy linkCC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

answered Jul 24, 2020 at 12:45

Michael HamptonMichael Hampton

250k4646 gold badges517517 silver badges986986 bronze badges

1

This is very helpful. Thank you. I found how to remove it, but now I know where header come from.

– Nick

Commented
Jul 24, 2020 at 12:58

Add a comment
|

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged

nginx

http-headers

.

The Overflow Blog

Ryan Dahl explains why Deno had to evolve with version 2.0

Featured on Meta

We've made changes to our Terms of Service & Privacy Policy - July 2024

Bringing clarity to status tag usage on meta sites

Report this ad

Related

1

Expires directive returned in the ngix server response header

7

Cache-control for permanent 301 redirects nginx

6

Nginx sending 2 Cache-Control headers

2

My Apache 2.2 local test server with php none cgi automaticly removes logged in ipad users

0

Apache / Nginx / Varnish - GZIP does not work on css, js

4

Nginx: using X-Accel-Expires with Cache-Control

0

varnish redirecting to backend url

0

"/robots.txt" is outside location "\.php$"?

Hot Network Questions

Adding equations of motion

The Reforger NPC is stuck underground. How do I get him to move?

How is Nationality Principle applied in practice?

The McDonald's Option

How many people could we get off of the planet in a month?

Is sudoku only one puzzle?

Why was the uncut gem stored in a fish?

In Moon, why does Sam ask GERTY to activate a third clone before the rescue team arrives?

Player A and B flip a coin alternatively till HT comes up. Player A goes first. Whoever flips the T wins. What is the probability that A wins?

How old were Phineas and Ferb? What year was it?

Multiple unds in a sentence

The meaning of “manage” in this context

bash script quoting frustration

Fitting 10 pieces of pizza in a box

C - mini string lib

How would Earth's plants change in this speculated Earth-like planet?

Kids' educational VHS series about a man who's friends with a parrot and a chimpanzee

Do linguists have a noun for referring to pieces of commendatory language, as a sort of antonym of 'pejoratives'?

Retroactively specifying `-only` or `-or-later` for GPLv2 in an adopted project

Series of discrete groups with a Lie group limit

Everyone hates this Key Account Manager, but company won’t act

Should I be worried about this giant crack?

block-structure matrix

Has any spacecraft ever been severely damaged by a micrometeorite?

more hot questions

Question feed

Subscribe to RSS

Question feed

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Server Fault

Tour

Help

Chat

Contact

Feedback

Company

Stack Overflow

Teams

Advertising

Collectives

Talent

About

Press

Legal

Privacy Policy

Terms of Service

Cookie Settings

Cookie Policy

Stack Exchange Network

Technology

Culture & recreation

Life & arts

Science

Professional

Business

API

Data

Blog

Facebook

Twitter

LinkedIn

Instagram

Site design / logo © 2024 Stack Exchange Inc;
user contributions licensed under
CC BY-SA
.
rev 2024.8.22.14349