Although CDW correlations are a ubiquitous feature of the superconducting cuprates, their disparate properties suggest a crucial role for pinning the CDW to the lattice. Here, we report coherent resonant X-ray speckle correlation analysis, which directly determines the reproducibility of CDW domain patterns in La1.875Ba0.125CuO4 (LBCO 1/8) with thermal cycling. While CDW order is only observed below 54 K, where a structural phase transition creates inequivalent Cu-O bonds, we discover remarkably reproducible CDW domain memory upon repeated cycling to far higher temperatures. That memory is only lost on cycling to 240(3) K, which recovers the four-fold symmetry of the CuO2 planes. We infer that the structural features that develop below 240 K determine the CDW pinning landscape below 54 K. This opens a view into the complex coupling between charge and lattice degrees of freedom in superconducting cuprates.