Other retailers like Costco, Target and Kroger are also joining the increasingly expensive battle for customers who want eggs and milk without leaving their couch.

“There is a lot of experimenting going on as everyone tries to figure out that last-mile delivery — it’s a tough economic equation to make work,” said Mike Knemeyer, a professor of logistics at Ohio State University. “But if you can, you’ll have a big head start on the others, and you’ll end up making money not just in groceries but on all of the things that you sell.”

The nexus of e-commerce and grocery sales is increasingly appealing to retailers.

“The thing that’s great about grocery is that it’s a pure traffic driver — no matter who you are, you need to get groceries every two weeks, which makes it an exception from all the other categories that keep retailers up at night,” said Matt Sargent, a retail expert at the consulting firm Magid.

But while the total grocery market is enormous — nearly $1 trillion annually in the United States — many customers still insist on seeing and touching their food in person before buying. Spending on online groceries is currently just $27 billion a year, or 3 percent of the total, according to Forrester Research, which specializes in technology.

Controlling costs is another major challenge. Grocery providers have grappled with the expense of packaging delicate produce and meats in ice packs and dispatching fleets of company-owned vehicles from distribution centers staffed around the clock.