varnish 4 vcl

vcl 4.0;
backend default
{
  .host = "127.0.0.1";
  .port = "8079";
}

sub vcl_recv
{
  if (req.url !~"^/Admin/")
    {
      unset req.http.cookie;
    }
  if (req.url  ~ "\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|woff|ttf|eot|svg)(\?|$)"){
	unset req.http.Cache-Control;
	unset req.http.Pragma;
  }
  if(req.url  ~ "\.(css|js)(\?|$)"){
    set req.url = "/s/min/?f=" + regsub(req.url, "^(.+)\?(.+)$","\1&\2");
  }
  if(req.url ~ "^/I/1/"){
    set req.url = regsub(req.url, "^/I/1/(.+)$" , "/I/v1.php/\1");
  }
}

sub vcl_backend_response
{
 set beresp.grace = 30s;
 if (bereq.url ~ "\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|woff|ttf|eot|svg)(\?|$)"){
  set beresp.ttl = 1w;
  set beresp.http.Cache-Control= "s-max-age=604800";
 }else{
  # set beresp.ttl = 30s;
  # set beresp.http.Cache-Control= "s-max-age=30";
 }

if (beresp.status == 404) { 
    	set beresp.ttl = 10s; 
    }
 if (beresp.http.Content-Type ~ "(javascript|text|json)")    {
      set beresp.do_gzip = true;
    }
  if (bereq.url !~"^/Admin/")    {
      unset beresp.http.set-cookie;
    }
}

sub vcl_deliver{
  if( obj.hits > 0 ){
    set resp.http.X-Cache = "HIT";
  }else{
    set resp.http.X-Cache = "MISS";
  }
  set resp.http.Server = "Hector Server v1.3";
  unset resp.http.X-Powered-By;
  unset resp.http.Via;

}