Title: Random code &#8211; issue with caching
Last modified: December 10, 2025

---

# Random code – issue with caching

 *  Resolved [l r](https://wordpress.org/support/users/lainyrache/)
 * (@lainyrache)
 * [5 months, 2 weeks ago](https://wordpress.org/support/topic/random-code-issue-with-caching/)
 * Hi
   I am using a random code script to show quotes on a template.
 *     ```wp-block-code
       $rows = get_field('quote' ); if( $rows ) { $index = array_rand( $rows ); $rand_row = $rows[ $index ]; $rand_row_quote = $rand_row['client_quote']; $rand_row_quote_source = $rand_row['quote_source']; ?> <div class="smquotebox"> <div class="smquoteboxin"> <blockquote> <?php echo $rand_row_quote; ?> <footer><?php $rand_row_quote_source; ?></footer> </blockquote> </div> </div>
       ```
   
 * This is working fine without caching, but when I enable caching it doesn’t work.
   
   Is there a way to exclude the random code from caching in the plugin, without
   excluding the whole page?(If I exclude the page in settings it works, but I would
   rather not exclude all the pages using this template)
 * Many thanks for any help!

Viewing 1 replies (of 1 total)

 *  Plugin Support [litetim](https://wordpress.org/support/users/litetim/)
 * (@litetim)
 * [5 months, 2 weeks ago](https://wordpress.org/support/topic/random-code-issue-with-caching/#post-18750680)
 * [@lainyrache](https://wordpress.org/support/users/lainyrache/) 
   HmmmmDo you have
   Server Litespeed Enterprise? You can use ESI. Then convert shortcode to ESI tag:
   [https://docs.litespeedtech.com/lscache/lscwp/admin/#turning-wordpress-shortcodes-into-esi-blocks](https://docs.litespeedtech.com/lscache/lscwp/admin/#turning-wordpress-shortcodes-into-esi-blocks)
   Other solution I would try is a AJAX request after page is loaded. This would
   be the terotical solution that would work and make sure is not cached.

Viewing 1 replies (of 1 total)

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Frandom-code-issue-with-caching%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/litespeed-cache/assets/icon-256x256.png?rev=2554181)
 * [LiteSpeed Cache](https://wordpress.org/plugins/litespeed-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/litespeed-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/litespeed-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/litespeed-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/litespeed-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/litespeed-cache/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [litetim](https://wordpress.org/support/users/litetim/)
 * Last activity: [5 months, 2 weeks ago](https://wordpress.org/support/topic/random-code-issue-with-caching/#post-18750680)
 * Status: resolved