set cache-control in a subfolder (php)

JoakimR nginx-forum at
Thu Nov 17 09:17:36 UTC 2016

Hi I'm trying to override my default cache-control in my /admin/ folder

	location /admin/ {
		add_header “Cache-Control: no-cache”;
		try_files $uri =404;
		access_log off;

but everything have a wrong cache-age by running curl -I

curl -I https://domain/admin/index.php
HTTP/1.1 302 Moved Temporarily
Server: nginx
Date: Thu, 17 Nov 2016 09:10:02 GMT
Content-Type: text/html;charset=utf-8
Connection: keep-alive
Set-Cookie: PHPSESSID=hf3slpa33833dt3hl168m4sv24; expires=Fri, 18-Nov-2016
09:10:02 GMT; Max-Age=86400; path=/
Expires: Sat, 19 Nov 2016 21:10:02 GMT
Cache-Control: public, max-age=216000
Last-Modified: Sat, 21 May 2016 01:04:48 GMT
Location: https://domain/admin/login.php?referrer=/admin/index.php
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff

I've tried all the directives from to try
overriding this

My goal is to have no-cache on all php files in this subfolder. Any one who
could help me?

Posted at Nginx Forum:,271004,271004#msg-271004

More information about the nginx mailing list