Leverage browser caching with varnish

Put following in your default.vcl file, all files that deliver with png,jpg,css add  http cache control header max-age

 

sub vcl_backend_response {
# Happens after we have read the response headers from the backend.
#
# Here you clean the response headers, removing silly Set-Cookie headers
# and other mistakes your backend does.
if (bereq.url ~ “\.(png|gif|jpg|swf|css|js)$”) {
unset beresp.http.set-cookie;
set beresp.http.cache-control = “max-age = 2592000”;

}
}

One thought on “Leverage browser caching with varnish

  1. Pingback: Apache Varnish ssl | Konkretor Blog, IT Stuff and more

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s