I have a problem with countdown timer in Magento 2 when Page Cache is enabled.

On page load the timer always start from the same time: e.g. 19:05:00 It's refreshed once if cache is flushed.

I have tried to use tag "cacheable="false" - but this disable FPC on page at all (the page load become too long).

I have also try to use $this->_isScopePrivate = true; in my block class, but this not help, such as timer depend on category attribute. (it use registry('category'))

Can anybody help with this?

  • Why do you not use js for timer?
    – KAndy
    May 20, 2016 at 14:22

1 Answer 1


Magento 2 FPC does not support hole punching. (It's not good for performance anyway.) You will have to implement the feature in JavaScript, using JS variables, cookies, local storage, or AJAX requests to handle any state or additional information you need.

This technique is how private or customer-specific data is handled across the entire Magento core in 2.0+. For example, go to your account dashboard, orders, address book, cart, or checkout, and note how the page contents all fill in after load: They aren't part of the page that's cached in FPC, they're filled in by JS after the page loads.

If you're counting down, maybe store the completion date and time on the page, then use JS to calculate how much time is left until then.

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.