I have timers/countdowns on my Product Pages. This code is written in PHP and is inserted as a block. The problem is, with the default M2 FPC these values get cached server-side.

I believe that Magento can't "Hole Punch" like Varnish. And attempting any workarounds lead to the entire page being invalidated.

Therefore, if I rewrite my PHP as JS, will this solve my problem as the value would be generated client-side?

1 Answer 1


Javascript can be cached, too. Meaning you will have FPC entries containing your JS markup. However as due to the nature of JavaScript it will be rendered every time in the Browser. Meaning that variables defined in the block will return cached values even if you process them via JS.

Lets say you have a block function called getCurrentTime() in your Block and use it as Getter for your JS (i.e. var currentTime = <?php echo $this->getCurrentTime(); ?>) it might return as cached.

However, you still can write methods in JS that are doing this for you. In the JS approach variables might not be cached at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.