If you do happen to be caught in a rip current, stay calm. It won't pull you under - it'll just pull you away from shore. If you try to fight the rip current and swim against it, you'll just get worn out. Instead - float!
If you're a good swimmer, swim parallel to shore until you've cleared the pull of the rip current. Swim with the waves, allowing them to push you to shore.
If you can, wave and yell to get the attention of lifeguards and people on shore to let them know you need help.