The current paradigm of cosmic formation and evolution of galaxy clusters foresees growth mostly through merging. Galaxies in the infall region or in the core of a cluster undergo transformations owing to different environmental stresses. For two X-ray luminous clusters at redshift z ~ 0.3 with opposite X-ray morphologies, RXCJ0014.3-3022 and RXCJ2308.3-0211, we assess differences in galaxy populations as a function of cluster topography. Cluster large-scale structure and substructure are determined from the combined photometry in the B, V, and R bands, and from multi-object optical spectroscopy at low resolution. A spectral index analysis is performed, based on the [OII] and Hdelta features, and the D4000 break, available for more than 100 member galaxies per cluster. Combination of spectral indices and FUV-optical colours provides a picture of the star formation history in galaxies. In spite of the potential presence of a small fraction of galaxies with obscured star formation activity, the average star-formation history of cluster members is found to depend on cluster-centric distance and on substructure. There is a sharp increase in star formation activity along two well-defined filamentary structures of the merging cluster RXCJ0014.3-3022, out to its virial radius and beyond, produced by luminous (L ~ L*) and sub-L* galaxies. Conversely, the regular cool-core cluster RXCJ2308.3-0211 mostly hosts galaxies which either populate the red sequence or are becoming passive. These results suggest the existence of a correspondence between assembly state and overall age of the stellar populations of galaxies inside the virialized region and in the surrounding large scale structure of massive clusters at z ~ 0.3. (Abridged)