Support

Account

Home Forums Front-end Issues Cache-Proof Random Image From Gallery

Solving

Cache-Proof Random Image From Gallery

  • How would you display a random image from a gallery field (img src or bg img) using a cache-proof method? In other words, the image needs to load randomly on each refresh.

    Thx.

  • You can’t prevent a browser from caching a page. Outputting HTML with a new random image every time would depend on what server side cache you’re using. It may be possible with some but you’d need to look into the cache that you’re using. The might be able to load the image using AJAX, but you’d need to vary the URL that is requested each time as well so that the browser thinks it’s getting something different.

  • Someone offered up this REST API and AJAX solution.Haven’t been able to test it yet. https://gist.github.com/airesvsg/2710de81f09613c456277ae3e38c2358

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Cache-Proof Random Image From Gallery’ is closed to new replies.