I have it working very well - as far as I can see Discourse behaves well towards Varnish and you can aggressively cache everything under the /assets directory.
backend discourse {
.host = "x.x.x.x";
.port = "81";
}
sub vcl_recv {
if (req.http.host == "forum.myhost.org.uk") {
set req.backend = discourse;
}
if (req.http.host == "forum.myhost.org.uk") {
if (req.url ~ "^/assets") {
return(lookup);
} else {
return(pipe);
}
}
Obviously there is more in my varnish config, but that is the basic / cache specific bit. I proxy through Apache, so in the virtual host have something like this:
<LocationMatch "^/assets/.*$">
Header set Cache-Control "public, max-age = 3600"
</LocationMatch>
In my setup, the max-age is used to tell varnish to cache, though different cache headings can be used.
There might be a few other things that can be safely cached (comments anyone?) though the above seems to work great.
It takes load off Apache, on which I run mod_security so the stack is both fast and pretty secure
)
Enjoy…