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”;

}
}

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 )

Google+ photo

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

Twitter picture

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

Facebook photo

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

w

Connecting to %s