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.";
    }
    }

  • 相关阅读:
    异常处理
    组合,封装
    自我介绍
    27python更多实例
    28python类代码编写细节
    29python运算符重载
    30python 类的设计
    31python类的高级主题
    32python异常基础
    33python异常编码细节
  • 原文地址:https://www.cnblogs.com/createyuan/p/3816032.html
Copyright © 2011-2022 走看看