A two-level system interacting with a cavity field is an important model for investigating the photon blockade (PB) effect. Most work on this topic has been based on the assumption that the atomic transition frequency is resonant with the fundamental mode frequency of the cavity. We relax this constraint and reexamine PB in a more general atom--cavity system with arbitrary atomic and cavity detunings from a driving field. The results show that when the signs of the atomic and cavity detunings are the same, PB occurs only in the strong-coupling regime, but for opposite signs of the atomic and cavity detunings, strong photon antibunching is observed in both the weak- and strong-coupling regimes and a better PB effect is achieved compared with the case when the signs are the same. More interestingly, we find that this PB arises from quantum interference for both weak and strong nonlinearities. These results deepen our understanding of the underlying mechanism of PB and may be help in the construction of single-photon sources with higher purity and better flexibility using atom--cavity systems.