invalidate the block cache

Created on 21 March 2024, 3 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

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States eric@erubino.net Washington DC

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

Comments & Activities

  • Issue created by @eric@erubino.net
  • πŸ‡ΊπŸ‡ΈUnited States eric@erubino.net 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;
    }
    }

Production build 0.69.0 2024