<p class="MsoNoSpacing">
</p><p class="MsoNoSpacing">I have my homepage cached as shown </p>
<p class="MsoNormal"><span style="font-size:9.0pt">location
= / {</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> if (-f
/var/www/statichtmls/during_build.html) {</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> return 503;</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> }</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> set $country_code $http_x_country_code;</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> set_if_empty $country_code
$geoip_country_code;</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> </span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> limit_req zone=pw burst=5 nodelay;</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> proxy_pass
<a href="http://localhost:82">http://localhost:82</a>;</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> proxy_set_header Host $host;</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> proxy_set_header X-Real-IP $remote_addr;</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> proxy_set_header X-Country-Code $country_code; </span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> proxy_set_header Accept-Encoding
"";</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> proxy_ignore_headers Cache-Control; </span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> proxy_ignore_headers Expires; </span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> proxy_ignore_headers X-Accel-Expires; </span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> add_header X-Cache-Status
$upstream_cache_status;</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> proxy_cache cache;</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> proxy_cache_key
$scheme$host$request_uri$cookie_sessionid$country_code; </span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> proxy_cache_valid 200 302 2m;</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> proxy_cache_use_stale updating;</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt">}</span></p>
<p class="MsoNoSpacing">But every time I hit the page as an anonymous user it
shows </p>
<p class="MsoNormal"><span style="font-size:9.0pt">X-Cache-Status:
EXPIRED </span></p><p class="MsoNormal"><span style="font-size:9.0pt"><br></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt">user$
curl -I <a href="http://site.com">site.com</a></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt">HTTP/1.1
200 OK</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt">Server:
ngx_openresty</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt">Date:
Fri, 19 Oct 2012 02:15:32 GMT</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt">Content-Type:
text/html; charset=utf-8</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt">Connection:
keep-alive</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt">Keep-Alive:
timeout=60</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt">Vary:
Accept-Encoding</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt">Vary:
Cookie</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt">Set-Cookie:
csrftoken=Dl4mvy4Rky7sfZwqek27hFrCXzWCi9As; expires=Fri, 18-Oct-2013 02:15:32</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"> GMT; Max-Age=31449600; Path=/</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt">X-Cache-Status:
EXPIRED</span></p>
<p class="MsoNoSpacing">I want to cache it both for logged in and anonymous and
it looks like the absence of session cookie is creating issues. </p>
<p class="MsoNoSpacing">How do I cache the homepage correctly?</p>
<p></p>