Link to home
Start Free TrialLog in
Avatar of FireBall
FireBall

asked on

Nginx No-cache of a page

Hello ,

we have a config as given below, but still pages are cached on the browser side until it is removed from the settings of chrome (we tested only on chrome but it is not stabil and this is enough for research)
I hope somebody has some experience about this problem

than you

server {
    error_log /etc/nginx/logs/human_check_errors ;
    listen xxxxxxxxx:80;
    access_log /etc/nginx/logs/human_check_logs main;
    root /home/php;
	


	location ~* \.(?:css|js)$ {
		expires           epoch;
	    
	}
	location ~* \.(?:ico|jpg|jpeg|gif|png|webp)$ {
		expires           epoch;
	    
	}
	location ~* \.(?:json|xml|rss|atom)$ {
		expires           epoch;
    }
    location ~* \.(?:3gp|7z|avi|bmp|bz2|csv|divx|doc|docx|eot|exe|flac|flv|gz|less|mid|midi|mka|mkv|mov|mp3|mp4|mpeg|mpg|odp|ods|odt|ogg|ogm|ogv|opus|pdf|ppt|pptx|rar|rtf|swf|tar|tbz|tgz|tiff|txz|wav|webm|wma|wmv|xls|xlsx|xz|zip)$ {
		expires           epoch;
    }
    location / {
	    #testcookie on;
	    fastcgi_cache_bypass 1;
	    fastcgi_no_cache 1;
	    fastcgi_pass   xxxxxxxxx:9000;
	    fastcgi_index  index.php;
		expires           epoch;
	    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
	    include        fastcgi_params;
    }
    location ~ .*\.(php|jsp|cgi|pl|py|htm|html)?$ {
	    #testcookie on;
	    fastcgi_cache_bypass 1;
	    fastcgi_no_cache 1;
	    fastcgi_pass   xxxxxxxxx:9000;
	    fastcgi_index  index.php;
		expires           epoch;
	    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
	    include        fastcgi_params;
        
    }
}

Open in new window



Cahits-MacBook-Pro:checksum_check cahiteyigunlu$ curl -I xxxxx.xxxxx
HTTP/1.1 200 OK
Server: nginx
Date: Sat, 26 Aug 2017 03:20:13 GMT
Content-Type: text/html
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: PHP/5.4.32
Expires: Thu, 01 Jan 1970 00:00:01 GMT
Last-Modified: Sat, 26 Aug 2017 03:20:13 GMT
Cache-Control: no-cache
Pragma: no-cache
X-Frame-Options: DENY
Set-Cookie: visits=1; expires=Sat, 26-Aug-2017 05:46:13 GMT

Open in new window

Avatar of HainKurt
HainKurt
Flag of Canada image

I see this on response

expires=Sat, 26-Aug-2017 05:46:13 GMT

Open in new window


so it is cachable...

try

expires           off;

Open in new window


so you can control your pages from pages...

or put a negative time here, so it is never cached...

response should be like this:

Expires: Thu, 01 Jan 1970 00:00:01 GMT
Cache-Control: no-cache

Open in new window


The Expires header shows a date in the past and Cache-Control is set with no-cache, which tells the browser to always ask the server if there is a newer version of the file (using the ETag header, like before).
Avatar of FireBall
FireBall

ASKER

The first result is when i am blacklisted , blacklist page , second result is when i am whitelisted that i need to see the white list page on the browser.
But , while curl returning the real server page's values i am still getting the first blocked page on my browser when i refresh the page


Cahits-MacBook-Pro:checksum_check cahiteyigunlu$ curl -I www.xxx.com
HTTP/1.1 200 OK
Server: nginx
Date: Sat, 26 Aug 2017 04:10:20 GMT
Content-Type: text/html
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: PHP/5.4.32
Expires: Tue, 03 Jul 2001 06:00:00 GMT
Last-Modified: Sat, 26 Aug 2017 04:10:20 GMT
Cache-Control: no-store, no-cache, must-revalidate, max-age=0
Cache-Control: post-check=0, pre-check=0
Pragma: no-cache
X-Frame-Options: DENY
Set-Cookie: visits=1; expires=Sat, 26-Aug-2017 06:36:20 GMT

Cahits-MacBook-Pro:checksum_check cahiteyigunlu$ curl -I www.xxx.com
HTTP/1.1 200 OK
Server: nginx
Date: Sat, 26 Aug 2017 04:10:55 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: PHP/5.6.31
X-Pingback: http://www.xxx.com/xmlrpc.php
Link: <http://www.xxx.com/>; rel=shortlink
Expires: Sat, 26 Aug 2017 04:11:55 GMT
Cache-Control: max-age=60
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Nginx-Cache-Status: EXPIRED
X-Server-Powered-By: Engintron

Open in new window

This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.