Some commentaries say that David wrote this when he was old, but don’t say why they make this conclusion. Some add it was during Absalom’s rebellion while he was in the Judean desert, already ascribed to Psalm 3 and probably 63. Of course, David could have wrote more than one or even two for one event. Evidence in the psalm, 2 Samuel 11-19, and related Psalms 69, 70, and 40 indicates their belief have merit. Also, Psalm 71 is included in the two Davidic Psalm-Prayers Books (I & II, Psalm 72:20). I have more evidence in my commentary on this psalm.
The psalm reveals that an old man, who believed and trusted in the Lord God Almighty his whole life (5-6), “a portent to many” (7), seen “troubles, many and bitter” (20), played the harp, sang, and composed psalms (22-23), now in trouble, did compose this psalm while he was being chased and about to be captured (10). Verse 5 and 17 says he trusted and was taught by the Lord, “…from my youth,” and verse 5 starts, “From birth…” Verse 9b says, “…when I am old… strength is gone.” Verse 18 says, “… old and gray…” Something David could truly say.
The psalm starts out with a request for deliverance and to never be put to shame, as Absalom shamed David by sleeping with his concubines in public (2 Samuel 14:22). The author wants God to hear him. “Give the command to save…” reminds me of the centenarian whose faith impressed Jesus with, “Just say the word and I know my servant will be healed.” Faith asks knowing that the Lord will can do.

