Created
August 30, 2016 21:39
-
-
Save atomsfat/82c488b2118d7639b15d28145f58ca31 to your computer and use it in GitHub Desktop.
Mobile Device Detection via User Agent RegEx Varnish
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
#Mobile detect https://gist.github.com/dalethedeveloper/1503252 | |
if(req.http.User-Agent ~ ".*(Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune).*") | |
{ | |
set req.http.X-ua = "mobile"; | |
}else{ | |
set req.http.X-ua = "desktop"; | |
} | |
sub vcl_hash { | |
hash_data(req.http.X-ua + ":" + req.url ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment