# Can shuffle be cached?

**URL:** <https://discourse.gohugo.io/t/can-shuffle-be-cached/54636>\
**Category:** support\
**Created:** [May 5, 2025, 12:13pm UTC](https://discourse.gohugo.io/t/can-shuffle-be-cached/54636 "2025-05-05T12:13:13Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [May 5, 2025, 9:54pm UTC](https://discourse.gohugo.io/t/can-shuffle-be-cached/54636/12 "2025-05-05T21:54:24Z")

</div>

@irkode’s suggestion to generate five random numbers is _significantly_ faster:

```plaintext
<p>Five random pages:</p>
<ul>
  {{ range seq 5 }}
    {{ with math.Rand | mul site.RegularPages.Len | math.Floor | int }}
      {{ with index site.RegularPages . }}
        <li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
      {{ end }}
    {{ end }}
  {{ end }}
</ul>

```

Using this approach with the example site referenced above, the build time increased by 10% instead of 22%.

---

_[View the full topic](https://discourse.gohugo.io/t/can-shuffle-be-cached/54636)._
