notes1
Anders Berg
andersb at vgnett.no
Wed Mar 1 02:08:18 CET 2006
I have been playing around with trying to structure/document the
Configuration Language:
http://klikk.vg.no/vcl.html
I just wanna ask if I am wasting my time before I continue?
Don't we need this in one form or another? Or have your rocket-speed
fingers already done this Poul?
Anders Berg
> -----------------------------------------------------------------------
Configuration Language
> XXX: include lines.
> BNF:
> program: function
> | program function
> function: "sub" function_name compound_statement
> compound_statement: "{" statements "}"
> statements: /* empty */
> | statement
> | statements statement
> statement: if_statement
> | call_statement
> | "finish"
> | assignment_statement
> | action_statement
> if_statement: "if" condition compound_statement elif_parts else_part
elif_parts: /* empty */
> | elif_part
> | elif_parts elif_part
> elif_part: "elseif" condition compound_statement
> | "elsif" condition compound_statement
> | "else if" condition compound_statement
> else_part: /* empty */
> | "else" compound_statement
> call_statement: "call" function_name
> assign_statement: field "=" value
> field: object
> field "." variable
> action_statement: action arguments
> arguments: /* empty */
> arguments | argument
> -----------------------------------------------------------------------
Sample request policy program
> sub request_policy {
> if (client.ip in 10.0.0.0/8) {
> no-cache
> finish
> }
> if (req.url.host ~ "cnn.no$") {
> rewrite s/cnn.no$/vg.no/
> }
> if (req.url.path ~ "cgi-bin") {
> no-cache
> }
> if (req.useragent ~ "spider") {
> no-new-cache
> }
> if (backend.response_time > 0.8s) {
> set req.ttlfactor = 1.5
> } elseif (backend.response_time > 1.5s) {
> set req.ttlfactor = 2.0
> } elseif (backend.response_time > 2.5s) {
> set req.ttlfactor = 5.0
> }
> /*
> * the program contains no references to
> * maxage, s-maxage and expires, so the
> * default handling (RFC2616) applies
> */
> }
> -----------------------------------------------------------------------
Sample fetch policy program
> sub backends {
> set backend.vg.ip = {...}
> set backend.ads.ip = {...}
> set backend.chat.ip = {...}
> set backend.chat.timeout = 10s
> set backend.chat.bandwidth = 2000 MB/s
> set backend.other.ip = {...}
> }
> sub vg_backend {
> set backend.ip = {10.0.0.1-5}
> set backend.timeout = 4s
> set backend.bandwidth = 2000Mb/s
> }
> sub fetch_policy {
> if (req.url.host ~ "/vg.no$/") {
> set req.backend = vg
> call vg_backend
> } else {
> /* XXX: specify 404 page url ? */
> error 404
> }
> if (backend.response_time > 2.0s) {
> if (req.url.path ~ "/landbrugspriser/") {
> error 504
> }
> }
> fetch
> if (backend.down) {
> if (obj.exist) {
> set obj.ttl += 10m
> finish
> }
> switch_config ohhshit
> }
> if (obj.result == 404) {
> error 300 "http://www.vg.no"
> }
> if (obj.result != 200) {
> finish
> }
> if (obj.size > 256k) {
> no-cache
> } else if (obj.size > 32k && obj.ttl < 2m) {
> obj.tll = 5m
> }
> if (backend.response_time > 2.0s) {
> set ttl *= 2.0
> }
> }
> sub prefetch_policy {
> if (obj.usage < 10 && obj.ttl < 5m) {
> fetch
> }
> }
> -----------------------------------------------------------------------
> _______________________________________________
> varnish-dev mailing list
> varnish-dev at projects.linpro.no
> http://projects.linpro.no/mailman/listinfo/varnish-dev
More information about the varnish-dev
mailing list