I am planning minor variations to HTML based on user-agent. Specifically, I would not be implementing ad codes (adsense and other third party ads) for certain user-agents (certain old browsers both on desktop and mobile). Other than the ad codes, the entire content will be the same for all user agents. For such minor variations, should I take any SEO precautions (for example, using HTTP vary header)?
Cloaking is only a problem if you treat search engine crawler user agents differently than normal users. Removing ads for a few normal users that have old browsers is not cloaking. You would still be treating Googlebot the same as the vast majority of human users.
Search engines might use the vary on the
User-Agent header if you were serving different mobile and desktop pages based on
User-Agent. I don't think that search engines are going to emulate crawling as an old browser and ever discover your variations. The
Vary header isn't going to be important or helpful for SEO in this case.
It is important to use the
Vary: User-Agent header for caching proxy servers and CDNs. Any system that caches your pages and returns them to multiple different users needs to know that every browser could get a different page.