varnish cache static content

  1. We are Caching here All Image Type and CSS & JS. and Caching for 50 Minutes.# vi /etc/varnish/default.vclsub vcl_recv {
    # what files to cache
    if (req.url ~ “\.(png|gif|jpg|jpeg|ico|txt|swf|css|js)$”) {
    return(hash);
    }
    }

sub vcl_backend_response {
# Caching the Static Content for 50 Min.
if (bereq.url ~ “\.(png|gif|jpg|jpeg|swf|css|js)$”) {
set beresp.ttl = 50m;
}
}

2. Check the VCL Writting is OK.
#varnishd -C -f /etc/varnish/default.vcl

3. Restart the Varnish Cache
# /etc/init.d/varnish restart

Leave a Reply

Your email address will not be published. Required fields are marked *

*