Our first service rifle was, um, not a rifle.
It was the M1795, .69 caliber flintlock musket. (19 years)
It was replaced by the .69 caliber M1812 in 1814. (2 years)
It was replaced by the .69 caliber M1816 in 1816. They didn't have an "A" designation so instead of M1816A1, we get M1822, M1835, M1840 and M1842. The M1842 being the first caplock. The Army didn't really consider them different guns, just different designations to keep track of small changes. (39 years)
Those models were technically still front line weapons all the way to 1855 when we get the .58 caliber M1855 rifle musket in 1856. Followed by the M1861, and M1863. (9 years)
The first breech-loader is the M1865 chambered in .58-60-500 rimfire. This is also the first Erskine Allin trapdoor to be type classified! (1 year)
Then we get a trapdoor chambered in .50-70-450, the M1866. Then The M1868 and M1870. (7 years)
The cost of converting old caplocks turned out to be prohibitive and since they were making all new guns anyway, they decided on, yet, another chambering for the trapdoor. The .45-70 M1873. Then M1884, and M1888. (19 years)
Smokeless supplanted black powder and the .30-40 Krag-Jørgensen M1892 hits the scene plus M1896 and M1898. (11 years)
Then the M1903 Springfield in .30-03. Then the M1903 in .30-06 in 1906. (33 years)
The M1903 was, kind of, replaced by the "Enfield" M1917, but the M1917 was replaced by the M1903 after WW1. The M1917 doesn't really count because it was a secondary standard.
We'd stopped using the year in the designation by 1936 when the M1 Garand is adopted. This "gas-trap" version only lasted 4 years when it was replaced by the M1 with a drilled gas port. (21 years)
The Garand was replaced in 1957 by the M14. (9 years).
The M14 was replaced by the XM16E1 in 1966, M16A1 in 1969. (17 years)
The M16A1 was replaced by the M16A2 in 1983. (11 years)
The M16A2 was replaced by the M4 in 1994. Then the M4 was changed to an M4A1 with a heavier barrel in 2014. (28 years)
The M4A1 was officially replaced by the M7 in 2022. (4 years)
The M7 was unofficially replaced by the XM8 in 2026.
So the all time record for shortest service life goes to the M1855 with just one year!
The longest being the 39 years of the M1816 musket and its variations.