How to clear server and browser cache in WordPress
I have a plugin that randomly displays images on the interface. It works well on a website without a cache, but for people using in siteground
or wpengine
, the same image is displayed instead of random. I tried to add a unique ID to each image like the code below, but it doesn't generate a unique ID in the server cache systems. Instead, the first generated ID is displayed each time with the same image.
<img src="image.png?v=<?php echo mt_rand( 1000, 9999 ); ?>" />
I also added 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 a solution to solve this problem? How can I show random image in all server cache websites.
+3
source to share