Skip to content

Instantly share code, notes, and snippets.

@atomsfat atomsfat/varnish.vcl
Created Aug 30, 2016

Embed
What would you like to do?
Mobile Device Detection via User Agent RegEx Varnish
#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
You can’t perform that action at this time.