Varnish vcl configuration for wordpress and xenforo caching

Discussion in 'Site & Server Administration' started by jhashan, Sep 1, 2016.

  1. #1
    Hi I have installed Varnish on my apache server, after installation I tested my site using isvarnishworking.com and see Age showing 0 and varnish not working properly.

    isvarnishworking.com report

    HTTP/1.1 200 OK
    Date: Thu, 01 Sep 2016 15:14:09 GMT
    Content-Type: text/html; charset=UTF-8
    Connection: keep-alive
    Set-Cookie: __cfduid=dc9efdbc45d351b68ed70201ad4e7e19e1472742846; expires=Fri, 01-Sep-17 15:14:06 GMT; path=/; domain=.example.net; HttpOnly
    Vary: Accept-Encoding,User-Agent
    X-Powered-By: PHP/5.5.9-1ubuntu4.14
    Cache-Control: max-age=3600
    Expires: Thu, 01 Sep 2016 16:15:56 GMT
    X-Varnish: 4594927
    Age: 0
    Via: 1.1 varnish-v4
    Server: cloudflare-nginx
    CF-RAY: 2db9ab8903c51864-EWR
    Content-Encoding: gzip
    
    Code (markup):
    My default vlc file is like this
    vcl 4.0;
    
    
    backend default {
    .host = "127.0.0.1";
    .port = "8080";
    }
    
    sub vcl_recv {
    if (req.method == "PURGE") {
    return (purge);
    }
    }
    
    sub vcl_backend_response {
    if (bereq.url ~ "\.(png|gif|jpg|swf|css|js)$") {
    unset beresp.http.set-cookie;
    set beresp.http.cache-control = "max-age = 2592000";
    }
    }
    
    sub vcl_deliver {
    
    }
    Code (markup):
    Please help me what settings I have to use for proper caching, on this server I have one Wordpress and one Xenforo site.
     
    jhashan, Sep 1, 2016 IP