It sounds like you're talking about otitis externa, an infection of the ear canal, a condition where you really should avoid getting any water in your ear.
You've already identified that the cap in question is not really waterproof.
The best way (and really the only way) to keep water out of your ear is to stay out of the water until your ear has had time to clear the infection.
To bathe, you can make a cheap waterproof ear plug by working a generous amount of petroleum jelly into a cotton ball, and using that as an earplug. You can also buy a special soft wax at most pharmacies. People roll a ball of the soft wax in their hands and press it into the outer ear.
Once the infection is healed, if you're not prone to such infections, you can use home-made or pharmacy bought ear drops after occasional swimming which will help maintain the proper environment to minimize infection in the ear. Use of a hair dryer on low to dry your ear is also useful.
High-grade silicone ear plugs can be used once the ear is healed, however, ear plugs can aggravate or cause the condition, so swimmers (or people occupationally required or recommended to wear ear plugs) usually consult with ear specialists to work out the best plug to use which will not cause damage to the ear canal, something critical for prevention.
Otitis Externa: A Practical Guide to Treatment and Prevention