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.
Justin Bieber crashes Drake Bell's album release party
Rosie O'Donnell unveils nearly 50-pound weight loss