Rework displaying dynamic information to JS for persistent caching

Created on 18 February 2025, 20 days ago

Problem/Motivation

The field displays pretty dynamic information, so caching on the backend can be pretty problematic.

Anyway, dropping the full page cache just to change the Open/Closed status is too much.

Also, we have to take into account the visitor's timezone, which can be different and can be detected right only on the frontend using JS.

Steps to reproduce

1. Get the page with static content, that is fully cached well and has good performance.

2. Add the Office Hours field display widget there, and get problems with always invalidated cache, or outdated information about Open/Close status.

Proposed resolution

To get rid of all these issues with caching and visitor's timezones we can just generate on the backend the static information and cache it on the Drupal side for unlimited time, and render the dynamic information like "Open/Close" status and highlighting of the current day - implement on the frontend using JavaScript.

What do you think about this idea?

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇦🇲Armenia murz Yerevan, Armenia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @murz
  • 🇳🇱Netherlands johnv

    Hi,
    Maintainer and user base have gone through numerous attempts to make the caching work nicely.
    See the issues with ' field cache' or ' anonymous'.
    You do not explain your use case.
    - Are you working with anonymous users od authenticated users?
    - are you using core cache modules
    - are you using external cache?

    In the code, you Will find a JS code that refreshes the field, for anonymous users when page_cache module is enabled.
    You Will also find an alter hook, to change the request time, so you can introduce time zone.
    That hook was introduced, but i never got feedback on that. So it should be working.

    So, please check the code once again, and report back with the result.

Production build 0.71.5 2024