Context : Galaxy mass and environment are known to play a key role in galaxy evolution : studying galaxy colors as a function of redshift , galaxy mass , and environment offers a powerful diagnosis to disentangle the role of each . Aims : We study the simultaneous dependence of the fraction of blue galaxies f _ { blue } on secular evolution , environment , and galaxy mass with a well-controlled cluster sample . We are thus able to study the evolution and respective role of the cessation of star formation history ( SFH ) in clusters caused by galaxy mass ( ” mass quenching ” ) or by environment ( ” environmental quenching ” ) . Methods : We defined an homogenous X-ray selected cluster sample ( 25 clusters with 0 < z < 1 and one cluster at z \sim 2.2 ) , having similar masses and well-defined sizes . Using multicolor photometry and a large spectroscopic sample to calibrate photometric redshifts , we carefully estimated f _ { blue } for each cluster at different galaxy mass and cluster-centric distance bins . We then fitted the dependence of f _ { blue } on redshift ( z ) , environment ( r / r _ { 200 } ) and galaxy mass ( M ) with a simple model . Results : f _ { blue } increases with cluster-centric distance with a slope \alpha = 1.2 _ { -0.3 } ^ { +0.4 } , decreases with galaxy mass with a slope \beta = -3.8 _ { -0.5 } ^ { +0.6 } , and increases with redshift with a slope \gamma = 3.2 _ { -0.5 } ^ { +0.7 } . The data also require for the first time a differential evolution with galaxy mass of f _ { blue } with redshift , with lower mass galaxies evolving slower by a factor \zeta = -4.1 _ { -0.9 } ^ { +1.1 } . Conclusions : Our study shows that the processes responsible for the cessation of star formation in clusters are effective at all epochs ( z \lesssim 2.2 ) , and more effective in denser environments and for more massive galaxies . We found that the mass and environmental quenchings are separable , that environmental quenching does not change with epoch , and that mass quenching is a dynamical process , i.e . its evolutionary rate is mass-dependent . Our study extends the downsizing -like scenario , where the most massive galaxies have their properties set at a very high redshift , to the cluster environment and all galaxies . It illustrates the need to disentangle galaxy mass and cluster-centric distance to properly estimate the behavior of f _ { blue } in clusters .