Nginx/SSI independent fragment caching
<p>I'm trying to set up a basic working Nginx+SSI example:</p>

<p>Nginx config (just the relevant parts, for brevity):</p>

<pre><code>ssi on;
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=my_cache:20m max_size=20m inactive=60m use_temp_path=off;

server {
  listen 80;
  server_name localhost;
  location / {
    proxy_cache  my_cache;
    proxy_set_header  Host $host;
    proxy_http_version  1.1;
    proxy_buffering  on;
    proxy_pass  http://127.0.0.1:81;
  }
}

server {
  listen 81;
  root /path/to/root;
  location ~ ^/.+\.php {
    fastcgi_pass  127.0.0.1:9000;
  }
}
</code></pre>

<p>ssi.php:</p>

<pre><code>&lt;?php
header('Cache-Control: public, s-maxage=5');
?&gt;
Time: &lt;?php echo time(); ?&gt;
Fragment time: &lt;!--# include virtual="/time.php" --&gt;
</code></pre>

<p>time.php:</p>

<pre><code>&lt;?php
header('Cache-Control: no-cache');
echo time();
</code></pre>

<p>The include works nicely:</p>

<blockquote>
  <p>Time: 1466710388
  Fragment time: 1466710388</p>
</blockquote>

<p>Now, a second later I would expect the page (ssi.php) to be still cached, but the <code>time.php</code> fragment to be fresh:</p>

<blockquote>
  <p>Time: 1466710388
  Fragment time: 1466710389</p>
</blockquote>

<p>However it stays completely the same for 5 seconds, after which the ssi page is updated along with the fragment:</p>

<blockquote>
  <p>Time: 1466710393 
  Fragment time: 1466710393</p>
</blockquote>

<p>I've done this before with ESI and Varnish, and expect this to work the same with SSI. Am I wrong in assuming this? I can't find an answer online for this, and have experimented with different cache-control headers, but I'm fairly sure this is the right way to do this. What am I missing here?</p>