Costa was targeted and fouled by numerous Stoke players during the 90 minutes and was struggling to keep his cool.
The Spain international was booked by referee Anthony Taylor for dissent in the first half as he became increasingly frustrated at the lack of protection he was getting.
Conversely, Costa was accused by Stoke manager Mark Hughes afterwards of using 'dark arts' to get the Stoke players in trouble.
But Cahill said: “I remember speaking to Diego in the first half, telling him just to keep his cool.
“He's on the edge at times, but that's the way he plays and they're a physical team.
“It's important we didn't get dragged into that kind of fighting battle and Diego handled himself really well up there.
“A little bit of protection from the referee maybe in the second half got him a few more fouls.
“Sometimes his reputation goes against him a little bit but he got a few free kicks and kept his head."
Costa has only been sent off once in his Chelsea career, although has been handed two retrospective bans by the Football Association in the past three years.
Asked if the 28-year-old if he might have struggled more in the past to stay on the pitch after being on the receiving end of Stoke's special treatment, Cahill added: “I don't know – if you feel you're getting fouled but not getting the decisions, it's going to frustrate you.
“You're not a robot. I think he felt like 'this is a foul, this is a foul' and some were, some weren't.
“But he battled through it, he kept going, and he hit the post which could have been a goal.
“It's important we keep him on the pitch because he's a match winner for us – at any time it can drop to him and he can finish which he's shown on loads of occasions this season.
“He didn't get sent off – that wasn't to be, so it was cool and he was fine.”