Welcome! Log In Create A New Profile

Advanced

Cache always shows expired status for anonymous users

Quintin Par
October 18, 2012 10:22PM
I have my homepage cached as shown

location = / {

if (-f /var/www/statichtmls/during_build.html) {

return 503;

}

set $country_code $http_x_country_code;

set_if_empty $country_code $geoip_country_code;



limit_req zone=pw burst=5 nodelay;

proxy_pass http://localhost:82;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Country-Code $country_code;

proxy_set_header Accept-Encoding "";

proxy_ignore_headers Cache-Control;

proxy_ignore_headers Expires;

proxy_ignore_headers X-Accel-Expires;

add_header X-Cache-Status $upstream_cache_status;

proxy_cache cache;

proxy_cache_key
$scheme$host$request_uri$cookie_sessionid$country_code;

proxy_cache_valid 200 302 2m;

proxy_cache_use_stale updating;

}

But every time I hit the page as an anonymous user it shows

X-Cache-Status: EXPIRED


user$ curl -I site.com

HTTP/1.1 200 OK

Server: ngx_openresty

Date: Fri, 19 Oct 2012 02:15:32 GMT

Content-Type: text/html; charset=utf-8

Connection: keep-alive

Keep-Alive: timeout=60

Vary: Accept-Encoding

Vary: Cookie

Set-Cookie: csrftoken=Dl4mvy4Rky7sfZwqek27hFrCXzWCi9As; expires=Fri,
18-Oct-2013 02:15:32

GMT; Max-Age=31449600; Path=/

X-Cache-Status: EXPIRED

I want to cache it both for logged in and anonymous and it looks like the
absence of session cookie is creating issues.

How do I cache the homepage correctly?
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Cache always shows expired status for anonymous users

Quintin Par October 18, 2012 10:22PM

Re: Cache always shows expired status for anonymous users

Quintin Par October 20, 2012 05:44AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 103
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready