Varnish 4.x and Craft Is there any vcl file to use with Craft? I saw here an amazing answer about Varnish and Craft and there is a 3.x configuration file but i need a newer one for Varnish 4 and i don’t know Varnish Configuration Language to port it myself
I'm by no means a Varnish pro, but I'm currently working on a project where we're running Varnish 4.0 in front of our nginx servers. I've uploaded an example of our VCL 4.0 file in this gist. It is based on the Varnish 4.0 template made by Mattias Geniar with some adjustments for Craft. 

It is NOT an exact port of the 3.x file you're referencing, so it's important to understand what it does. 

First of all, the 3.x file sets the ttl of cacheable requests in the VCL. Not sure if this is because it's harder to set the correct headers in ExpressionEngine, but I prefer to leave this to the backend server. If you don't set expire headers in your templates your pages won't be cached. To set a page to expire in 7 days you add this to your template:

{% set expiry = now|date_modify('+7 days') %}
{% header "Cache-Control: max-age=" ~ (expiry.timestamp - now.timestamp) %}
{% header "Pragma: cache" %}
{% header "Expires: " ~ expiry.rfc1123() %}


You can add all kinds of logic to this, setting different cache duration based on entry section, entry age, custom fields, or whatever. 

In the 3.0 example file, all asset folders (like /scripts, /assets/, /files, etc) are excluded from caching. This is probably a good idea in most cases, see the comments from the original 4.0 template regarding this. But, in my project all content files are uploaded to Amazon S3, so the only assets served by nginx is css, js, font files, and some small assets. I've opted to just let Varnish handle everything for now.

I'm taking a heavy handed approach to cookies, because I don't need them, and I had some problems removing the Craft ones. I've left in some of the original stuff from the template, mostly for reference.

All requests to the Craft admin is passed on to the backend server. I had some issues with just excluding /admin, because the control panel sometimes add index.php to the url, so I'm excluding everything that contains /admin or p=admin.

All in all, this might not be a perfect VCL file, but it seems to work fine. Running Varnish on a DigitalOcean 1GB/1CPU droplet, I've cut the response time on my test page from ~1.5s (unoptimized/uncached template with a lot of matrix going on) to 40ms. Static tests with ApacheBench within the local network shows Varnish delivering ~900 requests/sec. Pretty awesome, me thinks.

But comments and fixes are greatly appreciated. :)

I'm also working on a Craft plugin for purging URLs when entries are changed, but it's not working very well at the moment. 

UPDATE:
My Varnish Purge plugin is now available here. Also, check out Josh Angell's CacheMonster plugin here for a different take on the same problem.