1 1/2 cups (3 sticks) unsalted butter, at room temperature, plus more for the dish
1 cup granulated sugar
1 cup light brown sugar
3 cups all-purpose flour, plus more for the dish
1 teaspoon baking soda
3 teaspoons ground cinnamon
1/2 teaspoon freshly grated nutmeg
1/2 teaspoon kosher salt
5 Granny Smith apples, peeled, cored, and cut into a 1/2-inch dice
1 1/4 cups coarsely chopped pecans
2 1/4 teaspoons vanilla extract
For Caramel Glaze:
4 tablespoons unsalted butter
1/4 cup granulated sugar
1/4 cup light brown sugar
1/8 teaspoon kosher salt
1/2 cup heavy cream
Heat oven to 325 F. In a large bowl, using an electric mixer on medium-high, beat the butter and the granulated and brown sugars until light and fluffy, 3 to 5 minutes. Add the eggs, one at a time, beating after each addition.
In another bowl, combine the flour, baking soda, cinnamon, nutmeg, and salt. Using a wooden spoon, gradually add the flour mixture to the egg mixture. The batter should be very thick. Stir in the apples, pecans, and vanilla. Scrape the batter into a buttered and floured 9-by-13-inch baking pan.
Bake until a toothpick inserted in the center comes out clean, 50 to 60 minutes. Transfer to a wire rack. Let cool for at least 10 minutes while you make the Caramel Glaze.
To make Caramel Glaze, in a saucepan, over medium-low heat, melt the butter. Add the granulated and brown sugars and salt. Cook, stirring frequently, for 2 minutes. Stir in the cream and bring to a boil. Cook, stirring constantly, for 2 minutes. Remove from heat.
With a spatula, loosen the sides of the cake. If you want to remove it from the pan, invert it onto a baking sheet, then invert it again, right-side up, onto a platter. With a toothpick or fork, poke holes all over the surface.
Pour on the warm sauce. Serve warm or at room temperature, with ice cream, if desired.