I always hear this term, "洋人" ("Yang Ren"), in Chinese period films and television shows whenever the Chinese are referring to Westerners. Where did this term originate, why is it "yang ren," and for how long was this term used until some other term took over as the main definition for Westerners?
As for where it came from, 洋 yang has the meaning of "ocean" and in the sense of yangren refers to people from overseas, much like the English "overseas". You see the same prefixing with other foreign things like yangjiu meaning western alcohols like whiskey, or yangcong referring to western onions. The term has been in use for quite some time, though I'm not in a place where I can try to track down the oldest written record.