I hate to state the obvious but maybe not having unsafe sex in the first place is the most logical preventative.
I know where you're coming from, but let's avoid the contrived "safe" and "unsafe" sex jargon.
There is licit sex and illicit sex. That's all.