Processing of gas in distant cluster galaxies