cache gallery query