add_header 'Cache-Control' working only without location contextCache-control for permanent 301 redirects...
What happened to Captain America in Endgame?
Extension of 2-adic valuation to the real numbers
What is the most expensive material in the world that could be used to create Pun-Pun's lute?
Was there a shared-world project before "Thieves World"?
Does a large simulator bay have standard public address announcements?
How can I print the prosodic symbols in LaTeX?
Two field separators (colon and space) in awk
How to fry ground beef so it is well-browned
Rivers without rain
'regex' and 'name' directives in find
Why boldmath fails in a tikz node?
I preordered a game on my Xbox while on the home screen of my friend's account. Which of us owns the game?
Is there a way to generate a list of distinct numbers such that no two subsets ever have an equal sum?
What are the steps to solving this definite integral?
"Whatever a Russian does, they end up making the Kalashnikov gun"? Are there any similar proverbs in English?
Did the BCPL programming language support floats?
Can't get 5V 3A DC constant
How to have a sharp product image?
A Note on N!
Is Diceware more secure than a long passphrase?
Why do games have consumables?
Read line from file and process something
How to stop co-workers from teasing me because I know Russian?
How can I get this effect? Please see the attached image
add_header 'Cache-Control' working only without location context
Cache-control for permanent 301 redirects nginxUpdate Cache-Control max-age when srcache returns response from cacheNginx: using X-Accel-Expires with Cache-Controlnginx : add_header directive not workingCache-control no-cache but not on child folders in NginxAdding Cache-Control to Nginx for images, css, js, and fontsHow to avoid duplicated configuration in Nginx Location ConfigOrder of priority of response headers while deciding to cache a response in nginxNginx cache-control / expire headers will just not work
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I've installed nginx/1.10.3 (Ubuntu) and changed the original config file so that it is only slightly different at the top of the http context:
http {
add_header 'Cache-Control' 'no-cache';
and this is working. I will see 'no-cache' in the response headers when I access the index.html (tested with / and /index.html). And I can add more attributes like 'no-store', that will also work, it's really working here.
But I'd like to restrict the no-cache to only the index.html, and I can't get this to work.
http {
server {
location = /index.html {
add_header 'Cache-Control' 'no-cache';
}
}
does not work, no 'no-cache' appears in the response headers (tested with / and /index.html). Also not working are location / { ...
, and location ~
and location ~*
with a regexp.
I'm lost here. I'll reinstall nginx and check if there is a typo. Am I doing this correctly at all?
Edit: I purged and reinstalled nginx, did the same things again, got the same result.
nginx headers cache-control
bumped to the homepage by Community♦ 8 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I've installed nginx/1.10.3 (Ubuntu) and changed the original config file so that it is only slightly different at the top of the http context:
http {
add_header 'Cache-Control' 'no-cache';
and this is working. I will see 'no-cache' in the response headers when I access the index.html (tested with / and /index.html). And I can add more attributes like 'no-store', that will also work, it's really working here.
But I'd like to restrict the no-cache to only the index.html, and I can't get this to work.
http {
server {
location = /index.html {
add_header 'Cache-Control' 'no-cache';
}
}
does not work, no 'no-cache' appears in the response headers (tested with / and /index.html). Also not working are location / { ...
, and location ~
and location ~*
with a regexp.
I'm lost here. I'll reinstall nginx and check if there is a typo. Am I doing this correctly at all?
Edit: I purged and reinstalled nginx, did the same things again, got the same result.
nginx headers cache-control
bumped to the homepage by Community♦ 8 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Is that your http block configuration in it's entirety? If you haven't set up any directives specifying which locations/content/file types can be cached and how long those cached resources can be considered fresh then what exactly are you expecting Nginx to add here?
– miknik
Jul 10 '18 at 23:43
I had put it into the wrong configuration file, the location context seems to work here only in sites-availale/default.
– sorry
Jul 10 '18 at 23:59
add a comment |
I've installed nginx/1.10.3 (Ubuntu) and changed the original config file so that it is only slightly different at the top of the http context:
http {
add_header 'Cache-Control' 'no-cache';
and this is working. I will see 'no-cache' in the response headers when I access the index.html (tested with / and /index.html). And I can add more attributes like 'no-store', that will also work, it's really working here.
But I'd like to restrict the no-cache to only the index.html, and I can't get this to work.
http {
server {
location = /index.html {
add_header 'Cache-Control' 'no-cache';
}
}
does not work, no 'no-cache' appears in the response headers (tested with / and /index.html). Also not working are location / { ...
, and location ~
and location ~*
with a regexp.
I'm lost here. I'll reinstall nginx and check if there is a typo. Am I doing this correctly at all?
Edit: I purged and reinstalled nginx, did the same things again, got the same result.
nginx headers cache-control
I've installed nginx/1.10.3 (Ubuntu) and changed the original config file so that it is only slightly different at the top of the http context:
http {
add_header 'Cache-Control' 'no-cache';
and this is working. I will see 'no-cache' in the response headers when I access the index.html (tested with / and /index.html). And I can add more attributes like 'no-store', that will also work, it's really working here.
But I'd like to restrict the no-cache to only the index.html, and I can't get this to work.
http {
server {
location = /index.html {
add_header 'Cache-Control' 'no-cache';
}
}
does not work, no 'no-cache' appears in the response headers (tested with / and /index.html). Also not working are location / { ...
, and location ~
and location ~*
with a regexp.
I'm lost here. I'll reinstall nginx and check if there is a typo. Am I doing this correctly at all?
Edit: I purged and reinstalled nginx, did the same things again, got the same result.
nginx headers cache-control
nginx headers cache-control
edited Jul 10 '18 at 22:52
sorry
asked Jul 10 '18 at 22:21
sorrysorry
11
11
bumped to the homepage by Community♦ 8 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 8 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Is that your http block configuration in it's entirety? If you haven't set up any directives specifying which locations/content/file types can be cached and how long those cached resources can be considered fresh then what exactly are you expecting Nginx to add here?
– miknik
Jul 10 '18 at 23:43
I had put it into the wrong configuration file, the location context seems to work here only in sites-availale/default.
– sorry
Jul 10 '18 at 23:59
add a comment |
Is that your http block configuration in it's entirety? If you haven't set up any directives specifying which locations/content/file types can be cached and how long those cached resources can be considered fresh then what exactly are you expecting Nginx to add here?
– miknik
Jul 10 '18 at 23:43
I had put it into the wrong configuration file, the location context seems to work here only in sites-availale/default.
– sorry
Jul 10 '18 at 23:59
Is that your http block configuration in it's entirety? If you haven't set up any directives specifying which locations/content/file types can be cached and how long those cached resources can be considered fresh then what exactly are you expecting Nginx to add here?
– miknik
Jul 10 '18 at 23:43
Is that your http block configuration in it's entirety? If you haven't set up any directives specifying which locations/content/file types can be cached and how long those cached resources can be considered fresh then what exactly are you expecting Nginx to add here?
– miknik
Jul 10 '18 at 23:43
I had put it into the wrong configuration file, the location context seems to work here only in sites-availale/default.
– sorry
Jul 10 '18 at 23:59
I had put it into the wrong configuration file, the location context seems to work here only in sites-availale/default.
– sorry
Jul 10 '18 at 23:59
add a comment |
1 Answer
1
active
oldest
votes
I've put the lines into /etc/nginx/sites-available/default
now and it works. Previously I had made the location context in /etc/nginx/nginx.conf
and that seems to be wrong.
1
It's not "wrong" as such, you need to imagine the two files as actually one big file. Everything in nginx.conf applies to every site your Nginx instance is hosting, then this line in halfway downinclude /etc/nginx/sites-enabled/*;
tells Nginx to now also process all the files in that folder to find rules specific to each individual site/server
– miknik
Jul 11 '18 at 0:03
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "2"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f920386%2fadd-header-cache-control-working-only-without-location-context%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I've put the lines into /etc/nginx/sites-available/default
now and it works. Previously I had made the location context in /etc/nginx/nginx.conf
and that seems to be wrong.
1
It's not "wrong" as such, you need to imagine the two files as actually one big file. Everything in nginx.conf applies to every site your Nginx instance is hosting, then this line in halfway downinclude /etc/nginx/sites-enabled/*;
tells Nginx to now also process all the files in that folder to find rules specific to each individual site/server
– miknik
Jul 11 '18 at 0:03
add a comment |
I've put the lines into /etc/nginx/sites-available/default
now and it works. Previously I had made the location context in /etc/nginx/nginx.conf
and that seems to be wrong.
1
It's not "wrong" as such, you need to imagine the two files as actually one big file. Everything in nginx.conf applies to every site your Nginx instance is hosting, then this line in halfway downinclude /etc/nginx/sites-enabled/*;
tells Nginx to now also process all the files in that folder to find rules specific to each individual site/server
– miknik
Jul 11 '18 at 0:03
add a comment |
I've put the lines into /etc/nginx/sites-available/default
now and it works. Previously I had made the location context in /etc/nginx/nginx.conf
and that seems to be wrong.
I've put the lines into /etc/nginx/sites-available/default
now and it works. Previously I had made the location context in /etc/nginx/nginx.conf
and that seems to be wrong.
answered Jul 10 '18 at 23:57
sorrysorry
11
11
1
It's not "wrong" as such, you need to imagine the two files as actually one big file. Everything in nginx.conf applies to every site your Nginx instance is hosting, then this line in halfway downinclude /etc/nginx/sites-enabled/*;
tells Nginx to now also process all the files in that folder to find rules specific to each individual site/server
– miknik
Jul 11 '18 at 0:03
add a comment |
1
It's not "wrong" as such, you need to imagine the two files as actually one big file. Everything in nginx.conf applies to every site your Nginx instance is hosting, then this line in halfway downinclude /etc/nginx/sites-enabled/*;
tells Nginx to now also process all the files in that folder to find rules specific to each individual site/server
– miknik
Jul 11 '18 at 0:03
1
1
It's not "wrong" as such, you need to imagine the two files as actually one big file. Everything in nginx.conf applies to every site your Nginx instance is hosting, then this line in halfway down
include /etc/nginx/sites-enabled/*;
tells Nginx to now also process all the files in that folder to find rules specific to each individual site/server– miknik
Jul 11 '18 at 0:03
It's not "wrong" as such, you need to imagine the two files as actually one big file. Everything in nginx.conf applies to every site your Nginx instance is hosting, then this line in halfway down
include /etc/nginx/sites-enabled/*;
tells Nginx to now also process all the files in that folder to find rules specific to each individual site/server– miknik
Jul 11 '18 at 0:03
add a comment |
Thanks for contributing an answer to Server Fault!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f920386%2fadd-header-cache-control-working-only-without-location-context%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Is that your http block configuration in it's entirety? If you haven't set up any directives specifying which locations/content/file types can be cached and how long those cached resources can be considered fresh then what exactly are you expecting Nginx to add here?
– miknik
Jul 10 '18 at 23:43
I had put it into the wrong configuration file, the location context seems to work here only in sites-availale/default.
– sorry
Jul 10 '18 at 23:59