Nonlinear wave equations on time dependent inhomogeneous backgrounds