0
votes

Here's the present state in my Varnish. My question is, what is the best configuration for Android devices?

if (req.http.User-Agent ~ "iPhone") { set req.http.User-Agent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; en_us) AppleWebKit/525.18.1 (KHTML, like Gecko)"; } else if (req.http.User-Agent ~ "iPad") { set req.http.User-Agent = "Mozilla/5.0 (iPad; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5"; } else if (req.http.User-Agent ~ "Android") { // we don't do anything for Android devices right now since there // are just too many different ones. // // We could cache two versions, one mobile, one table for each // Android 2.0-2.4, however, we try to leave it be right now and // see how big the cache gets. } else { set req.http.User-Agent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; VOSA 1.0)"; } }

2

2 Answers

3
votes

There's a good devicedetect.vcl written by Varnish software themselves. It's alot easier to use than and provides more device types to grow with. It has a good android detection for both tablet and phones separated as well. You can find the source and good documentation on how to use it at:

https://github.com/varnish/varnish-devicedetect

Using it myself and have only good experience with the matching.

0
votes

@clarence suggestion to use varnish-devicedetect is a good one . for noobs like me who prefer a simple setup and detailed explanation. try out this tutorial at atomic object .

its pretty simple,straight forward and only need to add few vcl rules to the configuraration file