History effect in inhomogeneous superconductors