Limit history size in localStorage