Refactor by default
Improving the existing code keeps behaviour you can rely on and keeps the site earning while you work. It is the safer answer in most cases.
Signals that a rewrite is justified
- The platform underneath is end-of-life and cannot be patched.
- Every small change requires touching the same brittle module.
- The original authors are gone and nothing is documented or tested.
Strangler the migration
Route one section at a time behind the old site and keep both running. A big-bang cutover has no rollback and no honest estimate.
Measure the risk
Write down what a week of downtime costs. That number decides how much caution the migration deserves.