Known for its made-from-scratch pizzas, convenience chain Casey's General Stores (CASY 0.42%) has provided remarkable returns to its investors for the past 20 years: an average of more than 17% per year, which is approximately twice that of the S&P 500 over the same period. And this surprising consumer goods stock is trading close to its all-time high.

And, yes, there's good reason to think there could be still more in store for investors in the years ahead. Let's see why.

Community hubs built on pizza and gasoline

Casey's operates more than 2,400 stores across 16 states -- and with a vision that differentiates it from other convenience stores. The company shows its concern for small towns across the Midwest with its stated purpose "to make life better for communities and guests every day."

The company introduced its made-from-scratch pizza in 1984, and has grown into the fifth-largest pizza chain in the U.S. Casey's is known for its innovative pies, including a breakfast pizza, a taco pizza, and its new BBQ brisket pizza. To celebrate the 21st birthday of its breakfast pizza, Casey's recently launched a beer cheese breakfast pizza. Yup, you read that right.

But there's more to it than just pizza. In their respective towns, Casey's General Stores serve as a combination of convenience store, restaurant, gas station, electric vehicle (EV) charging station, and community gathering place. Its recession-proof consumer staples products and diversified business model have also allowed Casey's to thrive in a variety of economic conditions.

A high price for cheese

Although well-diversified, Casey's is struggling with increased operating costs due to inflation and supply chain disruptions. In the first quarter of its fiscal 2023, the company's inside margin -- that's its profit margin derived from non-fuel sales -- dropped 70 basis points from the same period last year.

The hardest-hit segment has been its margin for prepared food and dispensed beverages, which was down 540 basis points year over year. Higher commodity and ingredient prices (specifically cheese) have hurt profit margins most. Casey's endured a more than 30% jump in cheese prices year over year.

To combat narrowing margins for its flagship pizzas and other prepared foods, the company took steps during the quarter to improve its distribution network. For one, Casey's procurement team improved product availability in stores vs. last year, maintaining optimal inventory levels and preventing shortages.  The team also employed "strategic sourcing initiatives" to purchase goods at the best possible prices, keeping costs down on grocery products and general merchandise.

Record quarterly profits

Casey's set a new gross profit record in the first quarter of its fiscal 2023 at $836 million, a 16% year-over-year increase. Chief Financial Officer Steve Bramlage said that the record performance was driven by strong inside (non-fuel) and fuel profits, up 9% and 31% respectively.

Although prepared-food margins were down because of the spike in cheese prices, the company helped mitigate the damage by upping its grocery and general merchandise margin by nearly 34% year over year. According to Bramlage, the improved margin "is an impressive feat given the inflationary environment, and it's a testament to the merchandising team, their ability to manage margin through procurement, product mix, and retail adjustments."

Casey's brought in $4.5 billion in revenue in the first quarter, a noteworthy 40% increase year over year. And first-quarter diluted earnings per share were $4.09, a 28% improvement over last year as well as a first-quarter record.

Things look good for Casey's General Stores. If it continues to execute on its business model, this hidden-gem consumer staples stock could soon be reaching new all-time highs.