Cahill (7-10) yielded just two hits and overcame four walks en route to the victory, striking out four.
The runners moved up to second and third on a Nick Buss groundout, but pinch-hitter Matt Kemp struck out to end the game as Ziegler notched his 11th save.
Goldschmidt's homer was his 33rd for the Diamondbacks.
The Dodgers' Hyun-Jin Ryu (13-7) absorbed a complete-game loss despite yielding just the two runs on two hits. He walked one and struck out four National League West-leading Los Angeles, which dropped a fourth straight.
Exploding whale video goes viral on Internet
Selena Gomez drops F-bomb, walks off stage during Jingle Ball performance