Have your keys ready when you return home so you can open your door quickly. If you notice something wrong, don't go inside. Never admit strangers to your home, even if they are in uniform. Ask for a badge or other identification and read it through the window, if necessary. Don't answer personal questions or give out information about your family or a neighbor.
Every situation is different.
If the rapist is armed, resistance will be almost impossible. If You Are Raped Notice everything you can about the assailant and the scene.