There are many ways to prevent eye strain. It is all about reducing the stress on your eyes while you are actively using them. Try to figure out what element of the fatiguing activity is causing the problem and reduce it. Stare at the computer for long periods of time? Take a break every half hour or so to divert your eyes from the glare of the screen. Having the right lighting level helps as well.
When you already have eye strain, relieving it can be a simple process. Look to a different distance. Your eyes have two sets of muscles that keep your lens in focus. When one set of muscles is tired, stretch and relax them by using the other set. So if you are tired from reading, for example, stare off into the distance for a few minutes.
Or rest your eyes completely by taking a nap. (That always works for me.)