Caching the gallery for improving loading time