Skip to content

Instantly share code, notes, and snippets.

@atsu666
Last active November 28, 2018 11:27
Show Gist options
  • Save atsu666/e9912cfffca0539ebb401a473c186530 to your computer and use it in GitHub Desktop.
Save atsu666/e9912cfffca0539ebb401a473c186530 to your computer and use it in GitHub Desktop.
backend default {
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_recv {
set req.http.Host = req.http.host;
set req.http.X-Real-IP = client.ip;
set req.http.X-Forwarded-Host = req.http.host;
set req.http.X-Forwarded-Server = req.http.host;
set req.http.X-Forwarded-For = client.ip;
# UAグループ
if (req.http.User-Agent ~ "(?i)(iPhone|Android)") {
set req.http.X-UA-Device = "sp";
} else {
set req.http.X-UA-Device = "pc";
}
# GET以外はキャッシュしない
if ( req.method != "GET" ) {
return (pass);
}
# 通常ログインのアクセスならキャッシュしない
if ( req.http.Cookie && req.http.Cookie ~ "sid=" ) {
return (pass);
}
unset req.http.cookie;
return (hash);
}
sub vcl_hash {
hash_data(req.url);
hash_data(req.http.X-UA-Device); # UA(sp, pc)毎にキャッシュ
if (req.http.host) {
hash_data(req.http.host);
} else {
hash_data(server.ip);
}
return (hash);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment