V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  rails3  ›  全部回复第 17 页 / 共 20 页
回复总数  396
1 ... 9  10  11  12  13  14  15  16  17  18 ... 20  
@P99LrYZVkZkg 楼主,我要了,QQ: 二 悟 刘 似 吧 似
2013-12-18 11:53:23 +08:00
回复了 wzxjohn 创建的主题 MacBook Pro 想给MacBook Pro换SSD,求指点
840 e刚换的
2013-12-11 17:11:02 +08:00
回复了 mopig 创建的主题 问与答 「友家转运」有人用过没?八天了,一直没动~
前段时间买nexus5,本来寄到友家的,还好换了转运公司。
2013-12-11 15:39:54 +08:00
回复了 h2sky 创建的主题 Varnish 怎么处理Varnish 动态输出?
@h2sky .jsp 或 .action 结尾的直接把请求发到后端处理。
2013-12-11 15:38:25 +08:00
回复了 h2sky 创建的主题 Varnish 怎么处理Varnish 动态输出?
@h2sky

backend default {
.host = "172.16.7.23";
.port = "9091";
}


sub vcl_recv {

if (req.request == "CACHEPURGE") {
ban("req.http.host == " + regsub(req.http.host, ":6081", "") + " && req.url == " + req.url);
error 200 "Ban added";
}

if (req.request == "CACHEPURGEDIRECTORY") {
ban("req.http.host == " + regsub(req.http.host, ":6081", "") + " && req.url ~ " + req.url);
error 200 "Ban added";
}

if (req.restarts == 0) {
if (req.http.x-forwarded-for) {
set req.http.X-Forwarded-For =
req.http.X-Forwarded-For + ", " + client.ip;
} else {
set req.http.X-Forwarded-For = client.ip;
}
}

if (req.http.host ~ "(.*)domain.com") {
set req.backend = default;
}

if (req.http.host == "domain.com") {
set req.http.host = "www.domain.com";
}

if (req.url ~ "\.(jsp|action)$") {
return (pass);
}

if (req.url ~ "(.*)/(\?.*)?$") {
set req.url = regsub(req.url, "(.*)/(\?.*)?$", "\1/");
}

if (req.url ~ "\.html?.*") {
set req.url = regsub(req.url, "\.html?.*", "\.html");
}

if (req.url ~ "/index.html$") {
set req.url = regsub(req.url, "/index.html", "/");
}

if (req.http.Accept-Encoding) {
if (req.url ~ "\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|htm|html)$") {
remove req.http.Accept-Encoding;
unset req.http.Cookie;
unset req.http.Vary;
} 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;
}
}


return (lookup);
}

sub vcl_pipe {
return (pipe);
}

sub vcl_pass {
return (pass);
}

sub vcl_hash {
hash_data(req.url);
if (req.http.host) {
hash_data(req.http.host);
} else {
hash_data(server.ip);
}
return (hash);
}

sub vcl_hit {
if (req.request == "CACHEPURGE" || req.request == "CACHEPURGEDIRECTORY") {
purge;
error 200 "Purged.";
}
return (deliver);
}

sub vcl_miss {
if (req.request == "CACHEPURGE" || req.request == "CACHEPURGEDIRECTORY") {
purge;
error 200 "Purged.";
}
return (fetch);
}

sub vcl_fetch {
if (beresp.ttl <= 0s ||
beresp.http.Set-Cookie ||
beresp.http.Vary == "*") {
set beresp.ttl = 120 s;
return (hit_for_pass);
}

if (beresp.status == 404 || beresp.status == 503 || beresp.status == 500 || beresp.status == 502) {
set beresp.http.X-Cacheable = "NO: beresp.status";
set beresp.http.X-Cacheable-status = beresp.status;
return (hit_for_pass);
}

if (req.url ~ "\.(html|htm)$") {
set beresp.do_gzip = true;
if (req.url ~ "/list_") {
set beresp.ttl = 600s;
} else {
set beresp.ttl = 8h;
}
} else if (req.url ~ "\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf)$") {
set beresp.ttl = 8h;
} else {
set beresp.ttl = 8h;
}

return (deliver);
}

sub vcl_deliver {
set resp.http.x-hits = obj.hits ;
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT You!";
} else {
set resp.http.X-Cache = "MISS Me!";
}

remove resp.http.X-Varnish;
remove resp.http.Via;
remove resp.http.Age;
remove resp.http.Server;
remove resp.http.X-Powered-By;

return (deliver);
}

sub vcl_error {
set obj.http.Content-Type = "text/html; charset=utf-8";
set obj.http.Retry-After = "5";
synthetic {"
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>"} + obj.status + " " + obj.response + {"</title>
</head>
<body>
<h1>Error "} + obj.status + " " + obj.response + {"</h1>
<p>"} + obj.response + {"</p>
<h3>Guru Meditation:</h3>
<p>XID: "} + req.xid + {"</p>
<hr>
<p>kuakao cache server</p>
</body>
</html>
"};
return (deliver);
}

sub vcl_init {
return (ok);
}

sub vcl_fini {
return (ok);
}
2013-12-11 15:06:20 +08:00
回复了 h2sky 创建的主题 Varnish 怎么处理Varnish 动态输出?
varnish 可以根据url或后缀判断是否缓存
2013-12-09 14:40:45 +08:00
回复了 rails3 创建的主题 问与答 想买一台dell的2u服务器,欢迎大家推荐靠谱的商家
@hadoop 好的,谢谢了。
2013-12-09 14:20:06 +08:00
回复了 rails3 创建的主题 问与答 想买一台dell的2u服务器,欢迎大家推荐靠谱的商家
@hadoop 不要增值税发票大概可以便宜多少啊?
2013-12-09 13:19:02 +08:00
回复了 rails3 创建的主题 问与答 想买一台dell的2u服务器,欢迎大家推荐靠谱的商家
@hadoop 恩,刚才看了官方的报价,确实贵不少。
2013-12-09 13:08:20 +08:00
回复了 rails3 创建的主题 问与答 想买一台dell的2u服务器,欢迎大家推荐靠谱的商家
@czz811 好的,谢谢了
2013-12-09 13:01:39 +08:00
回复了 rails3 创建的主题 问与答 想买一台dell的2u服务器,欢迎大家推荐靠谱的商家
@manihome 我的QQ:尔悟刘思吧思
1 ... 9  10  11  12  13  14  15  16  17  18 ... 20  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5067 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 26ms · UTC 07:45 · PVG 15:45 · LAX 23:45 · JFK 02:45
Developed with CodeLauncher
♥ Do have faith in what you're doing.