OK.

Here is the answer for us. Here is a sample default.vcl. We are validating
the LastModified ( if (!beresp.http.last-modified) )
is changing when the core is indexed and the version changes of the index.

This does 10 minutes caching and a 1hr grace period (if solr is down, it
will deliver results up to 1 hr).

This uses the URL for caching.

You can also do:

http://localhost?PURGEME

To clear varnish if your IP is in the ACL list.


backend server1 {
    .host = "XXX.domain.com";
    .port = "8983";
    .probe = {
                .url = "/solr/pingall/select/?q=*%3A*";
                .interval = 5s;
                .timeout = 1s;
                .window = 5;
                .threshold = 3;
    }
}
backend server2{
    .host = "XXX1.domain.com";
    .port = "8983";
    .probe = {
                .url = "/solr/pingall/select/?q=*%3A*";
                .interval = 5s;
                .timeout = 1s;
                .window = 5;
                .threshold = 3;
    }
}
backend server3{
    .host = "XXX2.domain.com";
    .port = "8983";
    .probe = {
                .url = "/solr/pingall/select/?q=*%3A*";
                .interval = 5s;
                .timeout = 1s;
                .window = 5;
                .threshold = 3;
    }
}
backend server4{
    .host = "XXX3.domain.com";
    .port = "8983";
    .probe = {
                .url = "/solr/pingall/select/?q=*%3A*";
                .interval = 5s;
                .timeout = 1s;
                .window = 5;
                .threshold = 3;
    }
}

director default round-robin {
  {
        .backend = server1;
  }
  {
        .backend = server2;
  }
  {
        .backend = server3;
  }
  {
        .backend = server4;
  }
}

acl purge {
        "localhost";
        "10.0.1.0"/24;
        "10.0.3.0"/24;
}


sub vcl_recv {
   if (req.url ~ "\?PURGEME$") {
        if (!client.ip ~ purge) {
            error 405 "Not allowed. " + client.ip;
        }
        ban("req.url ~ /");
        error 200 "Cached Cleared";
   }
   remove req.http.Cookie;
   if (req.backend.healthy) {
     set req.grace = 15s;
   } else {
     set req.grace = 1h;
   }
   return (lookup);
}

sub vcl_fetch {
  set beresp.grace = 1h;
  if (!beresp.http.last-modified) {
        set beresp.ttl = 600s;
  }
  if (beresp.ttl < 600s) {
        set beresp.ttl = 600s;
  }
  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";
        }
}

sub vcl_hash {
    hash_data(req.url);
    return (hash);
}






On Tue, Jun 25, 2013 at 4:44 PM, Learner <bbar...@gmail.com> wrote:

> Check this link..
> http://lucene.472066.n3.nabble.com/SolrJ-HTTP-caching-td490063.html
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Varnish-tp4072057p4073205.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>



-- 
Bill Bell
billnb...@gmail.com
cell 720-256-8076

Reply via email to