Don’t cache the sidebar or sidebar element
-
Good afternoon Jose,
I have a challenge where a website that I am deploying has a sidebar where images are dynamically rotated each time the content of a new page is visited. This is fine until you add a “normal” cache plugin (WP Fastest Cache in this case) for speed. I am using a server with Apache and NGINX, so I can’t readily use LiteSpeed. Your plugin nicely solves that; however, I am unclear how to call the plugin correctly ( [content_no_cache id=”3328″ request=”remote”]) from the PHP on the image element (I presume you mean the DIV) to ensure the images that need to be rotated are not part of the page cache. Do you have an example of how to achieve this?
Thank you!
-
I have read more of your posts on the support forum.
Background, the site’s pages are built by PHP files calling a classic WordPress theme. I think, from your previous posts that it might not be possible to prevent an image from not being cached, in this way. Is this correct.
The code is written as a function.function showAdvert($reelPosition, $type)
{
global $advertNum, $advertBox, $advertStaticBox, $boxLink, $imageAltText, $dataStaticBoxDetails, $dataBoxDetails;if ($type == "static") { $staticAdvert = $advertStaticBox[$advertNum[$reelPosition]]; $fileSuffix = substr($staticAdvert, -3); ?> <a href="<?php echo $boxLink[$advertNum[$reelPosition]]; ?>" target="_blank" class="box-ad-click" data-box-ad-details="<?php echo $dataStaticBoxDetails[$reelPosition]; ?>" rel="nofollow"> <picture> <?php if ($fileSuffix == "jpg" || $fileSuffix == "JPG" || $fileSuffix == "jpeg" || $fileSuffix == "png" || $fileSuffix == "PNG" ) { ?> <source srcset="<?php echo $advertStaticBox[$advertNum[$reelPosition]]; ?>.webp" type="image/webp"> <?php } ?> <img <?=($reelPosition == 1 ? 'fetchpriority="low"' : '');?> src="<?php if (!empty($advertStaticBox[$advertNum[$reelPosition]])) { echo $advertStaticBox[$advertNum[$reelPosition]]; ?>" alt="<?php echo $imageAltText[$reelPosition];?>" width="300" height="250" <?=($reelPosition == 1 ? '' : 'loading="lazy"');?> /> <?php } ?> </picture> </a> <?php } if ($type == "animated") { // display jpeg, gif ,png ?> <a href="<?php echo $boxLink[$advertNum[$reelPosition]]; ?>" target="_blank" class="box-ad-click" aria-label="<?php echo $imageAltText[$reelPosition]; ?>" title="<?php echo $imageAltText[$reelPosition]; ?>" data-box-ad-details="<?php echo $dataBoxDetails[$reelPosition]; ?>" rel="nofollow"> <img <?=($reelPosition == 1 ? 'fetchpriority="low"' : '');?> src="<?php echo $advertBox[$advertNum[$reelPosition]]; ?>" alt="<?php echo $imageAltText[$reelPosition]; ?>" width="300" height="250" <?=($reelPosition == 1 ? '' : 'loading="lazy"');?> /> </a> <?php } } // end of function} // end of check function exists
Thank you!!!
You must be logged in to reply to this topic.