Cashner allowed one run and five hits, struck out five, and walked one in the Padres' 2-1 victory over the San Francisco Giants on Friday.
He retired the last 12 batters he faced, avenging a 2-0 loss to Tim Lincecum and the Giants last week.
Cashner (1-1) also picked up his second major league hit and scored San Diego's first run in its two-run third inning. He had a leadoff single to center and swiped second with two down.
Headley eventually came home on Yonder Alonso's base hit, giving the Padres a 2-1 lead.
That was it for San Diego against Lincecum (2-1), who struck out nine and allowed six hits in seven innings. The right-hander pitched 6 2/3 innings in his previous victory over the Padres.
"That was an impressive start," Giants manager Bruce Bochy said.
"We have to think that because we scored one run on a wild pitch. He was throwing hard with good stuff. We didn't do much off him last time, either. He shut us down; it's pretty simple."
Cashner's manager also was impressed with his performance on the mound.
"I think it was a carryover from his last start (against the Giants)," Padres manager Bud Black said. "He gave up a walk and a homer in that game, and that was his only flaw. Tonight he carried over a solid pitched game."
Cashner was pleased how he got better as the game went on.
"I thought I was struggling there at the beginning of the game," Cashner said. "I wasn't making pitches at the beginning of the game but I started settling in.
"I thought my curveball was really good, and I mixed it up and threw a lot of curveball first pitches tonight. (I'd) kind of like to have that one I bounced in the dirt in the first.
"I think in the last two years I've polished my changeup. My breaking ball is getting better, and I found my changeup later in the game. Everything is finally coming together."
Cashner and four relievers combined to retire 19 in a row before Buster Posey singled with one out in the ninth. Huston Street then struck out Hunter Pence before Brandon Belt singled to left, advancing pinch runner Joaquin Arias to third.
But Brandon Crawford grounded out to second to end the game, giving Street his fourth save.
San Francisco grabbed the lead in the first when Angel Pagan used his speed to manufacture a run. He singled, stole second, moved to third on a fielder's choice and scored on a wild pitch by Cashner.
San Diego Chargers WR Danario Alexander took batting practice, and Padres manager Bud Black was impressed, noting his bat speed. ... Black said OF Kyle Blanks, who injured his eyelid crashing into the wall in San Francisco last week, would be back in San Diego's starting lineup. He pinch hit in the seventh and grounded out to third. Giants LHP Jeremy Affeldt (right oblique strain) was scheduled to pitch a bullpen session Saturday. The reliever is eligible to come off the 15-day DL on Tuesday. ... Giants LHP Barry Zito (3-1, 3.42 ERA) will be on the mound Saturday night against Padres LHP Eric Stults (2-2, 4.70).