Why are you replacing the gas cap? Did you get a code to indicate an Evaporative Emission System fault?
There are literally a thousand and one reasons for the Check Engine light to come on. Going to the store and buying parts in hopes of hitting the right one is a poor troubleshooting technique. You really should buy an OBD II Scan Tool to pull the codes so you know which parts to put into your shopping basket.