V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
boro
V2EX  ›  Varnish

大家帮忙看下这段 Varnish 缓存规则是什么原因导致的语法错误

  •  
  •   boro · 2015-04-13 19:26:33 +08:00 · 4652 次点击
    这是一个创建于 3549 天前的主题,其中的信息可能已经有所发展或是发生改变。
    试了下Varnish官方给出的一个缓存应用实例,结果得到了下面这个错误:
    Message from VCC-compiler:

    Syntax error at

    ('input' Line 29 Pos 17)

    if (req.url ~ "\ (utm_ (campaign |? medium | source | term) | adParams | client | cx | eid | fbid | feed | ref (id | src) |? v (er | iew)) =" ) {

    ---------------- # --------------------------------- -------------------------------------------------- -------------------

    Running VCC-compiler failed, exit 1

    这个错在哪呢?

    全部缓存规则如下:

    backend default {
    .host = "127.0.0.1";
    .port = "8080";
    }

    sub vcl_recv {
    if (req.http.Accept-Encoding) {
    #revisit this list
    if (req.url ~ "\.(gif|jpg|jpeg|swf|flv|mp3|mp4|pdf|ico|png|gz|tgz|bz2)(\?.*|)$") {
    remove req.http.Accept-Encoding;
    } elsif (req.http.Accept-Encoding ~ "gzip") {
    set req.http.Accept-Encoding = "gzip";
    } elsif (req.http.Accept-Encoding ~ "deflate") {
    set req.http.Accept-Encoding = "deflate";
    } else {
    remove req.http.Accept-Encoding;
    }
    }
    if (req.url ~ "\.(gif|jpg|jpeg|swf|css|js|flv|mp3|mp4|pdf|ico|png)(\?.*|)$") {
    unset req.http.cookie;
    set req.url = regsub(req.url, "\?.*$", "");
    }
    if (req.url ~ “\?(utm_(campaign|medium|source|term)|adParams|client|cx|eid|fbid|feed|ref(id|src)?|v(er|iew))=”) {
    set req.url = regsub(req.url, “\?.*$”, “”);
    }
    if (req.http.cookie) {
    if (req.http.cookie ~ "(wordpress_|wp-settings-)") {
    return(pass);
    } else {
    unset req.http.cookie;
    }
    }
    }

    sub vcl_fetch {
    if (req.url ~ "wp-(login|admin)" || req.url ~ "preview=true" || req.url ~ "xmlrpc.php") {
    return (hit_for_pass);
    }
    if ( (!(req.url ~ "(wp-(login|admin)|login)")) || (req.request == "GET") ) {
    unset beresp.http.set-cookie;
    }
    if (req.url ~ "\.(gif|jpg|jpeg|swf|css|js|flv|mp3|mp4|pdf|ico|png)(\?.*|)$") {
    set beresp.ttl = 365d;
    }
    }

    sub vcl_deliver {
    # multi-server webfarm? set a variable here so you can check
    # the headers to see which frontend served the request
    # set resp.http.X-Server = "server-01";
    if (obj.hits > 0) {
    set resp.http.X-Cache = "HIT";
    } else {
    set resp.http.X-Cache = "MISS";
    }
    }
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1110 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 23:02 · PVG 07:02 · LAX 15:02 · JFK 18:02
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.