Glasgow lead the way on points differential after Ulster's surprising draw with Treviso in Belfast and remain on course to bring a Pro12 semi-final to Scotland for the first time.
Another brace of tries by Niko Matawalu was the highlight, the second of them ensuring Glasgow became the first team in competition history to claim five successive bonus-point victories.
However, it was Henry Pyrgos, brought on at scrum-half to allow the versatile Fijian to shift to the wing, who received the plaudits from the captain, Al Kellock.
"Ryan Wilson was superb and I also thought John Barclay was outstanding in the back row, but Josh Strauss got the man of the match award because of the way Henry started bringing our forwards into the game," Kellock said.
That inspired substitution after 52 minutes helped turn the match and Townsend, Glasgow's head coach, was highly critical of much of what had preceded it. "It was a poor performance in the first half . . . just unacceptable," he said. "However, getting to first place is a real boost ahead of this two-week break when we have some very tough games coming up, especially Leinster in our next match.
"It was fantastic to get another bonus point too. We did well in the Six Nations window last year, but to get maximum points this time around is more than we could have imagined."
In fairness to Townsend's team they had to deal with a couple of strange setbacks as Tim Swinson and Gordon Reid both suffered knock-outs.
The lock was first to have to be helped groggily from the field after getting things wrong in making a thunderous tackle. Reid followed minutes later after being unluckily struck on the back of the head by an off-balance punt from Peter Horne.
That continued the midfielder's sorry run with the boot after missing all his goal kicks the previous week. However, having otherwise received excellent reviews for that first start at stand-off against Ulster, Horne's overall confidence had clearly been unaffected.
He demonstrated that with a delightfully lofted pass which released his midfield partne r Alex Dunbar to create their team's first real break and even better was to come the next time the centre touched the ball as he received it in among considerable traffic just outside the 22. Little looked on until Horne accelerated into the first contact and while it looked as if he had made a mistake in ignoring the support of Matawalu on his right,
Horne's confidence in himself proved justified as two hand-offs gave him sufficient room and momentum to do it all himself.
Duncan Weir converted from close to the posts and for a period after that it looked like Glasgow might run riot, but they spurned two great opportunities after setting up overlaps on the right wing.
They were made to pay for that as a fine passage of Cardiff play, orchestrated by the elegant Rhys Patchell, took the visitors into the home 22 where the stand-off released Luke Hamilton. The No.8 took it in close and after a couple of rucks Josh Navidi managed to sneak over from close range, Patchell converting to level the scores.
Cardiff were more than playing their part in proceedings, with Patchell continuing to impress and their ambition earned two chances for their stand-off to put them ahead, the second of them with the last kick of the first half, Weir having struck from long range in between times.
Trailing 13-10, Glasgow started the second half purposefully but again failed to take their chances, first when they lost control of the ball after a driving maul had taken them to the try-line, then when Barclay knocked on as he looked set to go over from a well-executed back-row move off the back of a five-metre scrum.
Cardiff were growing in confidence and the match was being played at a fearsome pace as Pyrgos was brought on, sending Matawalu to the right wing.
More than one Glasgow player was looking heavy legged, Horne among them as he tracked back into his 22 to pursue a cleverly angled Patchell kick.
He found the energy to put up a high ball and give chase, however, and that was sufficient to force the knock-on that effectively turned the game. Horne latched on to the loose ball and fed Pyrgos who fired it to Matawalu and the Fijian saw the space behind the defensive line, kicked ahead and won the race.
Now Glasgow's tails were up and they registered their third try when a succession of rucks gradually sucked in more and more defenders until the ball was sent out to the uncovered Weir who strolled in for a try he converted himself as word filtered through that Ulster had failed to beat Treviso.
The try that took Glasgow to the top soon followed, a quick tap penalty by Pyrgos allowing DTH van der Merwe to challenge the Cardiff midfield defence, and he drew two men to him before sending Matawalu scampering clear down that right touchline once more for the bonus-point score.
Contextual targeting label: