Problems, need help? Have a tip or advice? Post it here.
2 posts Page 1 of 1
I have this code which I have tried as raw PHP and as Couch PHP wrapped code instead:

Code: Select all
<?php
                                    if (rand(0,100) > 50) {
                                        echo "<img src='/images/image1.png' alt='Image 1'>"; }
                                    else {
                                        echo "<img src='/images/image2.png' alt='Image 2'>"; }
                                ?>


I want it to randomly display one image or the other.

Is there no way to do this without completely disabling caching for this page?
Hi,

If caching is enabled, it does not matter if the output was rendered using raw PHP or Couch - the page would be cached nevertheless.

As you correctly mentioned - you'll need to disable caching for that particular page to avoid this.
As an alternative, you could try using client-side JS to manipulate the output.
2 posts Page 1 of 1