Last active
November 28, 2018 11:27
-
-
Save atsu666/e9912cfffca0539ebb401a473c186530 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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