For Drupal 7, there is Authcache module. In Drupal 8, you could use Dynamic Page Cache from core.
You could also use some JavaScript. If you have random data to display, you could display them all, hidden by default and use javascript to display one of them each time. Or you could use AJAX, request a URL that will return your new block content, on each page refresh. Disable cache for specific blocks has more information that can help you.
If you have multiple dynamic blocks in your website, my suggestion is to use a module, as it will take you less time to implement it. Writing JavaScript for each dynamic block will take you more time, to implement it and maintain it.