Beleaguered quarterback Colin Kaepernick gave the San Francisco 49ers reason to feel optimistic despite their last-second loss at the New York Giants on Sunday night.

Kaepernick rebounded from a pair of woeful efforts with a strong performance against the Giants, throwing for 262 yards and two touchdowns while not commiting a turnover for the first time during the four-game losing streak.

More from FoxSports

"Kap played his butt off, man. I take my hat off to him," wide receiver Anquan Boldin told reporters after the game. "It just looked like he was having fun. He was himself. And that's what I'm used to seeing."

The 49ers scored a total of 28 points over their previous three contests, but finally were able to generate consistent offense. Kaepernick directed three second-half touchdown drives, all covering at least 80 yards.

"It was good offensively to get in a rhythm like that," Kaepernick said. "Something we can build on moving forward. But we have to win games."

Kaepernick admitted to playing cautiously in a Week 4 loss to Green Bay, but he connected on passes of 25 yards to Torrey Smith and 26 to Boldin in leading San Francisco to a go-ahead touchdown with 1:45 to play.

MORE NEWS: Want stories delivered to you? Sign up for our NFL newsletters.