invalidate the block cache

Created on 21 March 2024, 9 months ago
Updated 12 July 2024, 5 months ago

Problem/Motivation

The usajobslisting block doesn't have any way to know when there are new jobs that should invalidate the cache

Steps to reproduce

configure module for agency, add usalistings block to page, then add a new job posting to usajobs. After 20 hours of waiting only the original jobs show and the new job will only show once you clear the site cache.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States ericrubino Washington DC

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

Comments & Activities

  • Issue created by @ericrubino
  • πŸ‡ΊπŸ‡ΈUnited States ericrubino Washington DC

    I am able to fix this in a preprocess hook but I think it should be fixed in the module itself.

    Here is what I used in my preprocess hook

    /**
    * Implements hook_preprocess_HOOK() for block.html.twig.
    */
    function themename_preprocess_block(&$vars) {
    if($vars['plugin_id'] == 'your-block-id') {
    //-- This sets the block cache to 6 hours.
    $vars['#cache']['max-age'] = 21600;
    }
    }

  • Status changed to Fixed 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States phoang
  • Status changed to Fixed 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States phoang
  • πŸ‡ΊπŸ‡ΈUnited States phoang
Production build 0.71.5 2024