Lengthening the flange helps remove the weld line from the flange's larger bolt surface, which helps reduce the thermal stresses that occur at the weld line during startup/shutdown operations. Shortening the flange makes the thermal stresses much worse at the weld line, and high temperature applications will have to consider using extraordinary QC measures to ensure that there are no "stress raisers" within the weld to lead to a failure. The fatigue damage is worst for austenitic stainless steel flanges as the combination of yield stress, thermal conductivity and density is worse than for ferritic alloys, but some ferritic alloys have a weld "soft zone" that acts as a "metallurgical notch".Bottom line is , use the longest flange you can fit in the pipe while retaining the ability to inspect ( and repair) the weld root pass at the ID.
"...when logic, and proportion, have fallen, sloppy dead..." Grace Slick