Pull Random Record from HubDB Each Time a Page Loads


#1

Hi,

I’m trying to display a random record from a HubDB database each time a page loads. To do that I:

  1. Created a template with a Custom Module with the following Hubl:

{% for row in hubdb_table_rows(675381, “&orderBy=random()&limit=1”) %}
the value for row {{ row.hs_id }} is {{ row.content }}
{% endfor %}

That accomplishes the task of randomizing the result on the first page load. But if I refresh, it doesn’t go retrieve another random record.

Is there a way to do this?


#2

Hi @Chadr,

HubL is evaluated when the page is served, and your page is likely cached, so I wouldn’t expect it to return another random row. Does it load a new random row if you refresh without cache (command+shift+R on a mac)?


#3

Any way to test it on Chrome on a PC?

Assuming that’s the problem, is there any way to force the page to not load the cached version, or better yet not load the cached piece of the page that contains that code?