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, if using.
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.