I've used Handifoam and a few other similar products over the years. (I read someone recently recommend a product by Hilti) Handifoam has 2 styles of guns- one is steel and supposedly is built to last longer. The other is a cheaper plastic gun which seems to work just as good if not better. They are pretty pricy so you'll want to take care of them. I tended to try to clean the steel guns out between cans and it seems that all it does is gunk out the inside of the gun. So I've found that if you take one can off, just spray cleaner on whatever mess you can see before you screw on the next can. I do this as quickly as I can- in just a few seconds to avoid exposing the inside of the gun to the elements where it could start to get gunked out. The only problem with the plastic guns is that I've broken 2 of them and boy does it make a mess when you throw something in the back of the truck and it breaks the nozzle off of the gun.
I almost always use Handifoam around exterior doors (wood frames) or patio doors (wood frames) but I would never use it around vinyl. You also need to have fresh foam- many brands will put expiration dates on their cans. The old cans tend to get syrupy and either won't expand as a fresh can would, or they don't tack up as quickly as a fresh can would.
Around vinyl windows, if there is 1/8" I'll caulk it because you can't get any significant insulation in there no matter what you try. If there is at least 1/4", I'll use cans of Dap Latex Door and Window Foam. It's pretty expensive, and doesn't work good at all if it gets cold. I've found that it works great to set an oven to "warm" and keep the cans toasty on the middle rack of the oven with the oven door open. It seems you get the most out of the cans that way too. Dap Latex will not overexpand, but it also only works well for gaps that are from about 1/4" to 5/8". Any bigger gap than that and it's cost prohibitive to use.