Preheat the oven to 325°F. Grease a 9x13-inch baking dish or spray with nonstick cooking spray.
In a medium bowl, whisk together the flour, baking soda, salt, and apple pie spice.
In a large mixing bowl, beat the softened butter and granulated sugar until light and fluffy, about 2 to 3 minutes.
Beat in the eggs one at a time, then mix in the vanilla extract.
Gradually add the dry ingredients to the wet ingredients, mixing just until combined.
Fold in the diced apples and chopped nuts, if using. The batter will be thick.
Spread the batter evenly into the prepared 9x13-inch baking dish.
Bake at 325°F for 45 to 55 minutes. Start checking the cake at 45 minutes. The cake is done when a toothpick inserted into the center comes out clean or with a few moist crumbs.
While the cake is baking, make the caramel glaze. Melt the butter in a small saucepan over medium heat.
Stir in the brown sugar and heavy cream. Bring the mixture to a gentle boil and cook for about 2 minutes, stirring constantly.
Remove from the heat and stir in the vanilla extract and a pinch of salt, if using.
Allow the baked cake to cool for about 10 minutes. Poke holes over the top with a skewer or fork, if desired.
Slowly pour the warm caramel glaze evenly over the warm cake. Allow the glaze to soak into the cake before slicing and serving.