To the other good advice here, I would add that it sometimes requires some management of your relationships with other civs to stay ahead in tech. Someone may have a tech that you want but they won't trade it with you because they don't like your religion or civics. If you are "spiritual" you can switch religion or civics for a turn without any anarchy and see if that opens up any trades.
Another thing to do is to try to get the computer players to go to war with each other. It's not always an option, but sometimes you can get a couple of the lower ranked CPs to go to war with the leader, which will shift everyone's production away from city improvement and to military production. You can also declare war on them yourself if you are comfortably far away, to keep them busy building units. I have rarely had any luck getting them to give you techs after the conclusion of wars, but they will sometimes. But the damage you do to your economy with war wearniness may not be worth it.
Always develop spare luxuries and resources and keep trying to find someone to trade them with. I think printing press gives you extra commerce from towns, and other civics like free religion also boost your technology. Windmills boost commerce at the cost of some production from hills.
You don't need a lot of cities to generate beakers, you just need cities that are founded in the right places and have the right development. If you use F1 to look at the beaker production of all of your cities, you might find that most of your beakers are being produced by only 2 or 3 cities. As an experiment, I played 2 games using China on the Earth map (exact same starting point and surrounding civs). In one I expanded as much as possible and captured a lot of cities; in the other, I focused on building up my empire, spreading my religion, and optimizing my luxuries, resources, improvements, great people, and trade. I wound up researching modern techs like physics and biology about 100 years faster with the builder strategy than with the expansion strategy, and won the space race against Frederick, who had a big empire and a lot of science production. In the expansion strategy I was building a lot of units, which take production time and cost money to support. In the builder strategy I was spending a lot of time with my cities producing research. I have to say, though, that the expansion strategy was more fun.