Circumvent Cache?

Permalink
Hi, I have a site where we've turned on full page caching to improve speed - which it really does. The problem though is that I use some PHP - C5 code to display random background images from a set. This doesn't work when caching is enabled - only when it's off.

The code is this:

$fs = FileSet::getByName('background_home');
$fileList = new FileList();
$fileList->filterBySet($fs);
$fileList->filterByType(FileType::T_IMAGE);
$files = $fileList->get(100,0); //limit it to 100 pictures

$size = sizeof($files);
$random = rand(0, $size - 1);
$theFile = $files[$random];
?>
<img src="<?php echo $theFile->getRecentVersion()->getRelativePath();?>" class="bgimage"/>

Is there a way to get this to work when caching is enabled?

thanks

 
dmennenoh replied on at Permalink Reply
I figured it out. I just used PHP to write out a JS array and then used JQuery to replace the image from one in the array.