I have a plugin that randomly displays images on front-end. It's working good on non cache website, but for people using in siteground or wpengine, the same image is showing instead of random. I tried appending the unique id to each image like the below code, but it is not generating the unique id on server cache systems. Instead, it is showing the first time generated id with the same image every time.
<img src="image.png?v=<?php echo mt_rand( 1000, 9999 ); ?>" />
I also added the below code for siteground cache (SG Optimizer WP Plugin), but it still won't work:
if (function_exists('sg_cachepress_purge_cache')) {
sg_cachepress_purge_cache();
}
Is there any solution to solve this problem? How can I show random image on all server cache websites, too.
If you have the same name for images. Then Why not give each image a different name.