MageStack natively supports the
Vary: User-Agent header, however, as it isn't a setting applicable to all stores, it is disabled by default.
To enable the User-Agent vary header, you only need to set a single variable in your vhosts configuration,
___general/example.com.conf (where example.com is your chosen domain), and add
set $magestack_vary_user_agent true;
Then restart Nginx via Monit.