zoukankan      html  css  js  c++  java
  • linux服务之varnish

    https://www.varnish-cache.org/installation/redhat
    varnish是现在很流行的一个HTTP(80)缓存加速解决方案,
    varnish是基于内存的缓存加速.
    Varnish 4.0:
        rpm --nosignature -i https://repo.varnish-cache.org/redhat/varnish-4.0.el6.rpm
        yum install varnish

    Installing Varnish Cache is as simple as enabling our package repository and installing the packages. Varnish Cache 4.0 is supported on EL6, and Varnish Cache 3.0 is supported on EL5 and EL6.

    sub vcl_recv {
    if (req.request == "PURGE")
    {if (!client.ip ~ purge)
    {error 405 "Not allowed.";}
    return(lookup);
    }
    if (req.http.host ~ "^google.com") {                  #web1对应的域名
    set req.backend = web1;}
    elseif (req.http.host ~ "^(www)|(my).baidu.com") {        #web2对应的域名
    set req.backend = web2;}
    else {
    error 404 "Caesar's cache-server ! QQ: 189717888"; #如果域名不在以上范围的出错提示
    #set req.backend = web1;
    }
    if (req.request != "GET" && req.request != "HEAD") {
    return(pipe);
    }
    elseif (req.url ~ ".(php|cgi)($|?)")                #动态页面直接通过,不缓存
    {
    return(pass);
    }
    return(lookup);
    }
    sub vcl_hit {
    if (req.request == "PURGE") {
    set obj.ttl = 0s;
    error 200 "Purged.";
    }
    }
    sub vcl_miss {
    if (req.request == "PURGE") {
    error 404 "Not in cache.";
    }
    }

  • 相关阅读:
    SDUSTOJ 1466
    UVa
    51Nod
    UVa
    easyui-启用禁用方法
    设置系统时间
    移除/添加属性
    .net生成二维码图片
    Mysql数据库误删恢复
    js 加减乘除运算
  • 原文地址:https://www.cnblogs.com/createyuan/p/3816032.html
Copyright © 2011-2022 走看看