Fix Field cache for anonymous users using Cron job in Status formatter

Created on 29 September 2022, over 1 year ago
Updated 14 April 2023, about 1 year ago

Issue status as per 14-apr-2023, comment #24, version 8.x-1.8:
"Cron job is definitely not the answer. Commit [# 3354203-5] sets a max-age =0 for anonymous users when Status formatter is used"

Issue status as per 1-jan-2023, comment #15, version 8.x-1.8:
"setting a custom cache tag on pages with time-dependent content and invalidating those cache tags manually via hook_cron()."
Keeping this ticket open, since this not an ideal situation, but apparently the best, since Drupal core does not invalidate pages for anonymous users.

Problem/Motivation

I really enjoy the office hours drupal module but I have one tiny problem with it.

When I'm logged in as an administrator the open/close trigger is set correctly and everything works fine.

After a few days of investigating the behavior as guest user (not logged in into drupal in a normal browser tab or private browser tab to force downloading the page) I found out that the wrong open/close state is cached for guest users.

When I cleared the drupal cache (as logged in administrator) the correct status is shown for guest users until the next trigger event. If the trigger time is reached, then there is no exchange of the status.

Steps to reproduce

1. installed the module as normal
2. created content type with 1 office hours field set
Display settings of the node type are: Display as plain text, show only open days, week starts on Monday, day notation is long, 24 hour format (9:00), current status are shown after hours
3. created 1 node based on the node type of point no. 2
4. to show the office hours with status open/closed indicator I created a views block to show this 1 entity
5. Disabled caching of this views block to make sure that the status indicator is updated immediately when the trigger times are reached for opening and closing indicator.
6. On the node page itself the exchange the current status indicator seems to work
7. but the related block with this 1 node based on office hours seems to be cached so the current status indicator never changes his status until I clear all the drupal caches.

I also tried to create a block based on the office hours content type and node and used fields.
the result is the same. status indicator will not update as expected.
I also disabled the views caching in advanced settings of views but the render cache of drupal is still active to avoid correct current state of the status indicator. The office hours node is not affected of this behavior.

Can someone give me some ideas to make the current status indicator work in views blocks?

Thanks everyone for help

πŸ› Bug report
Status

Closed: won't fix

Version

1.8

Component

Code - formatter

Created by

πŸ‡©πŸ‡ͺGermany Rikibu

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024