Filters that act by adsorbing contaminant onto their pore walls will experience a decrease in porosity over time, and may eventually block. As adsorption will generally be larger towards the entrance of a filter, where the concentration of contaminant particles is higher, these effects can also result in a spatially varying porosity. We investigate this dynamic process using an extension of homogenization theory that accounts for a macroscale variation in microstructure. We formulate and homogenize the coupled problems of flow through a filter with a near-periodic time-dependent microstructure, solute transport due to advection, diffusion, and filter adsorption, and filter structure evolution due to the adsorption of contaminant. We use the homogenized equations to investigate how the contaminant removal and filter lifespan depend on the initial porosity distribution for a unidirectional flow. We confirm a conjecture made in Dalwadi et al. (2015) that filters with an initially negative porosity gradient have a longer lifespan and remove more contaminant than filters with an initially constant porosity, or worse, an initially positive porosity gradient. Additionally, we determine which initial porosity distributions result in a filter that will block everywhere at once by exploiting an asymptotic reduction of the homogenized equations. We show that these filters remove more contaminant than other filters with the same initial average porosity, but that filters which block everywhere at once are limited by how large their initial average porosity can be.