Will HTML changing via PHP code in child theme purge the cache?
-
Hi,
I have a Woocommerce client site for a restaurant that has a menu page. You are able to add items to your cart from either the menu page or from individual product pages. The Add to Cart button text says “Add to Cart” during business hours and “See More” (since online ordering is disabled) after-hours. The way I change this text is by having a PHP function in my child theme that checks what day/time it is and then returns what the button text should be. However, I’ve noticed issues where the text doesn’t change to “Add to Cart” at the start of business hours and to “See More” after the business day is over. I figure that it’s due to the HTML page being cached in Cloudflare, so for the last several days I’ve just been manually purging the cache for the Menu page when needed.
However, sometimes it does seem to auto-purge. I’ll load the website at 10:59 AM and it’ll say “See More,” and then when business hours start at 11 AM I’ll refresh and it’ll now say “Add to Cart.”
What is expected behavior here? My intuition tells me that the button text should NOT change automatically due to the HTML page being cached, and that I will need to write a cronjob to purge the Menu page on a schedule. Side note: I would prefer not to exclude this page from caching due to page speed reasons; I’d rather just purge it twice a day via cronjob.
- You must be logged in to reply to this topic.