- 🇫🇮Finland jhuhta
I'm sorry to tell but the caching is still not quite right: please reopen the issue. (Found this issue again because my workaround patch stopped applying.)
The max-age calculation works, and the status flag kind of works - but only if the caching layers are not doing their things. In a project, we have the Page Cache and Dynamic Page Cache on, then Varnish and a CDN in front. To my understanding, Varnish is repeating what the Page Cache knows after an additional page load, and maybe there's no mechanism for them to update their knowledge about the max-age being spent already at a moment of time.
But to my surprise, the problem actually is reproducible on a local too, just having the Drupal caches on!
Steps to reproduce:
* have all Drupal caching on
* set the closing time to be something that happens soon and let the time pass
* reload page. The status flag should change to "closed" but it doesn't. Neither for authenticated nor unauthenticated requests.The content updates on reload if page_cache & dynamic_page_cache modules are disabled, or if the node is re-saved with no changes, or drush cr is run.
For us to be able to use this open/closed formatter at all, we really need to have a mechanism to update its content dynamically. Hence, my patch rerolled here against the current dev / 1.8. You can test the patch by retrying the steps above. You might see the old value flashing briefly before it gets updated.
- 🇳🇱Netherlands johnv
@jhuhta, thanks for your feedback.
Normally drupal best practice says to open a new issue. But let us decide on that later.I havesome questions, but they are nicely anwered in your post: anonymous user vs. authenticated user? Both mentioned caching modules activated or not:
-- Internal Dynamic Page Cache - "Caches pages, including those with dynamic content, for all users."
-- Internal Page Cache - "Caches pages for anonymous users and can be used when external page cache is not available."Drupal core handles both differently, and has some other problems, so reasons for the problem might be:
- The module calculates a wrong expiration timetimestamp (This should be corrected in the module)
- The expiration timestamp is not propagated correctly from field level to page level (This should not be a problem of this module,and must be solved in core)
- The caching for anonymous user is flawed. As work-around, a cron job for table cache_render is added in 🐛 Fix Field cache for anonymous users using Cron job in Status formatter Closed: won't fix . Regarding this, please check 🐛 Cron for cache handling breaks badly Fixed where we are actively working on it.The problem for anonymous users should also be solved: display the node, wait for the time to expire, run cron, re-display the node.
Is that the case, too?
There should be no problem with authenticated users (at least in my basic test system). So, I am surprised by that test result.I understand your solution is to move the open/closed status to JS. In the past, I discarded that solution, since all errors were due to calculation errors in the office_hours module.
At this point, I am happy with your solution, since it is better than the cron job solution.
I will review it. I think it is beter to open a new issue "Handle Status formatter in JS"
Please check the other issues.Alos, it might be needed to refresh the complete formatter, since the module now supports exception dates and seasons.
- 🇫🇮Finland jhuhta
Thank you for your reply! As per your advice, I opened a follow up issue: ✨ Fix Field cache for anonymous users using JS callback in Status formatter Fixed . Let's continue the discussion there about my potential solution.
By removing just one of the *_cache modules, I was able to get the status working for either anonymous or authenticated users, but I don't have the exact results here anymore.
I'm not yet familiar with the new Seasons feature, and we have implemented the opening time exceptions in a custom way long time ago.