"No disrespect, but I didn't know who their quarterback was," linebacker Ahmad Brooks said. "We got some good pressure on him. That helped us."
Davis was sacked five times, twice each by Brooks and Dan Skuta. They carried the day, keeping the St. Louis Rams' offense stalled and giving Colin Kaepernick a chance to warm up in a 31-17 victory Monday night.
Kaepernick threw for 343 yards and three touchdowns for the 49ers, who erased an early 14-point deficit. The defense stepped up again when Dontae Johnson returned an interception for a TD in the final minute to seal it.
"Talk about an opportunity; I had the chance to make a play," Johnson said.
Brandon Lloyd, Anquan Boldin and Michael Crabtree each caught a scoring pass for the 49ers (4-2), who have won three in a row. The 49ers permitted one first down on St. Louis' first six possessions of the second half.
"We've had the ball in every game with a chance to either win or tie," Davis said. "That's where hopefully my experience will help, the more opportunities I get.
"You've got to be able to go win games at the end."
Kaepernick had plenty of time to throw and wasn't sacked.
"We just want to win," Kaepernick said. "Whatever it takes, if we're up with the lead or if we have to come from behind."
Kaepernick found Boldin zipping across the end zone for an 11-yard touchdown pass, capping a go-ahead 80-yard drive to start the second half. As the Niners were taking the 17-14 lead, several fans in the upper deck unfurled a large banner above the video board on the opposite end of the stadium as part of ongoing protests about the Michael Brown shooting in suburban Ferguson in August.
San Francisco then added to its advantage when Kaepernick connected with Crabtree for a 32-yard score with 13 seconds left in the third.
The Rams had one last chance to tie the game, but Johnson returned an interception 20 yards for the clinching score with 53 seconds to go.
"We always see different looks in a game," Skuta said. "They hadn't done some of the things they did early. We adjusted and we kept playing; that's something we do really well."
St. Louis wore throwback uniforms -- royal blue and bright yellow -- to honor its 1999 Super Bowl title team and represented that winning squad very well for a short time. Guard Adam Timmerman joined wide receivers Isaac Bruce and Torry Holt for an impromptu bob 'n' weave TD dance in the end zone at halftime.
The Rams haven't had a winning season since the Greatest Show on Turf petered out in 2003. They doubled their first-quarter scoring for the year with a start that mimicked their previous home game, in which they led Dallas 21-0.
They lost that one 34-31, and this one was all San Francisco the rest of the way.
The 49ers scuffled to a 1-2 start coming off a third straight appearance in the NFC Championship Game but have won 13 of their past 14 in October.
Davis was 21-of-42 for 236 yards. He threw for 300 yards each of the previous two games with six touchdown passes.
Three of Davis' four interceptions have been returned for touchdowns, all in the fourth quarter at home.
The 49ers had four penalties before the end of their first possession, three accepted, and one the rest of the way. One of the early miscues, illegal contact on Eric Reid, handed the Rams a second first-and-goal on their opening drive capped by Cunningham's TD behind extra lineman Tim Barnes.
Rookie Tre Mason's first career carry was a 24-yarder that might have gone the distance had he not run into teammate Brian Quick. Three plays later, Kendricks got well behind the defense on a 22-yard catch that made it 14-0 late in the first.
The 49ers inched back on Phil Dawson's 54-yard field goal, his 10th in a row with four beyond midfield. They were backed up at their own 5 inside the two-minute warning but declined to play it safe, and Lloyd whipped Janoris Jenkins in single coverage on an 80-yard touchdown catch with 14 seconds left in the half.
"We had Brandon Lloyd on a double move," Kaepernick said. "We liked the matchup. He did an amazing job."
How the Denver Broncos can win their offseason
Retaining players such as Justin Simmons, Tim Patrick, Alexander Johnson and Phillip Lindsay is a start, as is adding to the quarterback position.
From Curtis Samuel to draft, Washington has options to add speed at WR
All eyes are on the quarterback situation, but adding a deep threat on offense is a priority and there are several playmakers available.
Arizona Cardinals' Kyler Murray donates 60,000 meals to North Texas Food Bank
Kyler Murray, who is from the Dallas area, donated 60,000 meals to the North Texas Food Bank in the wake of last week's crippling winter storm.
What QB does Kiper have the Pats trading up to get?
Mel Kiper Jr. projects the Patriots will trade up to take North Dakota State QB Trey Lance, and Louis Riddick gives high praise for Lance, saying he could be the wildcard of this draft.
Los Angeles Rams' Sean McVay reflects on good times with Jared Goff
Rather than focus on what wrong with Jared Goff, Rams coach Sean McVay wanted to reflect on the good times with his former quarterback on Thursday.
Ex-Washington Football Team employees ask NFL to release report findings
Twenty former Washington Football Team employees asked Roger Goodell to release the final report of an investigation into the organization's conduct.