Liquid 'now' date not updating on page refresh

Shopify Partner
31 0 9

Hi, I'm working on something that will only allow customers to place orers on certain items after a certain date has passed, which is specified in the product metafields, if the current time is before the unix timestamp defined in the metafield the add to cart button should not work. I've written it out in Liquid and it mostly works fine, however the time returned by the 'now' object seems to be cached on Shopify's server. I've found an older thread where the last comment explains my issue very well:


Here's the code I'm using to get the current timestamp: {% assign now_timestamp = 'now' | date: '%s' | plus: 0 %}

I have it write the value of this variable to the console on page load and sometimes it can go minutes, or even hours without changing. Keep in mind that this Liquid block is on the product page so it should be reflecting the accurate time. I don't want to use JS to get the current time locally as this would be far less secure. Is there any way that this can be fixed?

1 Like
Shopify Partner
1838 176 671

Hi Adam Sanderson

Out of luck there. Unless you want to write an app, JavaScript will be your only friend :-(

I turn coffee in to code - since 1998
Shopify Partner
2130 100 296

About liquids filter "date" not showing correct current time, i.e. not updating every page load

This is ironically a feature of shopify's platform aggressive rendering and then caching of assets(pages,images) there's no simple way around this. 

So in liquid when you use the date filter the page is rendered on the server that page is cached with the moment in time of creation and wont change until either the template is edited again or something causes the shopify cache to invalidated and update.

I think there used to be liquid trick to get the cache to update more often but when you get down to it you

A) use javascript for simple frontend timer, B) have a custom app for time sensitive where time actually matters

If this not working like you thought it would annoyed you, please contact and request they make the liquid date filter documentation better by explaining this gotcha as your not the first and wont be the last

Problem Solved? ✔️Accept and ? Like the solution so you can help others.
Buy me a coffee ☕ or donate to
Confused? Busy? Buy a custom solution