You want to use edge side includes. Basically, your pages use ESI links like this:
<div class="articles">
<esi:include src="/path/to/article/1"/>
<esi:include src="/path/to/article/2"/>
<esi:include src="/path/to/article/3"/>
</div>
Now in Varnish, have this:
sub vcl_fetch {
set beresp.do_esi = true;
}
or in Varnish 4:
sub vcl_backend_response {
set beresp.do_esi = true;
}
When the above code goes through Varnish, Varnish will replace each esi:include
with the contents of the URL /path/to/article/1
. You can cache the page itself for a few minutes, and each article for days.