Shooting modern US commercial ammo all the above advice is good. Some benchrest shooters clean every 20 rounds, some only when accuracy is affected.
Now, if you are shooting foreign milsurp ammo or US suplus ammo made before the early 1950s, ASSUME it to be corrosive primed.
Corrosive primed ammo the rifle should be cleaned as soon after shooting as practical, that day, or no later than the next day, if you are in a humid environment, and if not, still should be cleaned within a day or two.
Cleaned PROPERLY for corrosive primed ammo (which involves a little more work than the cleaning needed for non-corrosive ammo, look it up,
)
If you don't, or don't do it right, the chemical salts left in the bore (and everywhere else powder gas goes) WILL CAUSE RUST!! and, in high humidity, it can begin in a matter of hours!!!
.22 rimfire is still a different matter. Modern .22s unlike centerfires, seem to shoot their best with well fouled barrels. many have reported their .22RF becoming LESS accurate after they cleaned the barrel, and not getting the previous level of accuracy back until a few hundred rounds had been fired.
If your .30-06 groups suddenly get bigger, for no apparent reason, clean the bore. IF that doesn't return things to normal, THEN start checking the rifle for changes, loose screws, scope & mount, etc.