If you look at the date on boxes of pasta, for example, the best buy or expiration date is YEARS out. Those I out in 2 qt canning jars and vacuum seal for protection against infestation.
We are lucky to have ample storage space, so we can avail ourselves of the use of mylar bags in the Costco 45 liter plastic tubs for rodent protection, and then, as you say, limit acid foods in cans.
We too have pastas stored in various ways, from full vacuum to oxygen absorbers. Both ways mitigate the problem of insect pests in purchased goods.