Add "404 lifetime" to module to help with performance tuning

Created on 7 May 2025, 3 months ago

Problem/Motivation

-The current code deletes the HTML file every cache clear or cron run.
-Some sites will run cron quite frequently, resulting in the 404 page being thrown out a lot more often than necessary.

Steps to reproduce

-View a 404 page, you get a generated 404.html page, nice job module!
-Trigger cron. 404.html page goes away. Wow that was fast...

Proposed resolution

-Add a config page with a cache lifetime setting.
-Break HTML delete code into it's own function.
-Cache clear will now call delete function directly instead of the hook cron function.
-Hook cron will now only delete 404html if lastRunTime + cacheLifetime <= NOW

Remaining tasks

User interface changes

API changes

Data model changes

-Add config for cache lifetime.
-Stash somewhere smaht lastRunTime

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jnicola

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

Merge Requests

Comments & Activities

  • Issue created by @jnicola
  • πŸ‡ΊπŸ‡ΈUnited States jnicola

    Here's my patch on some initial work.

    Cache clear always deletes
    Cron checks against state of when 404 was last generated
    Standardized some calls to strings and such to keep code DRY

  • πŸ‡ΊπŸ‡ΈUnited States pookmish

    @jnicola, The patch no longer applies after the merge of the meta tag change. Can you please move this change into a MR. It will be easier for review and any feedback that might be needed.

  • πŸ‡ΊπŸ‡ΈUnited States jnicola

    I'll try and get that out here soon!

  • Merge request !3Add minimum lifetime functionality. β†’ (Open) created by jnicola
  • Status changed to Needs work 4 days ago
  • πŸ‡«πŸ‡·France johnatas

    Hi @jnicola,

    Are you using a Cron manager?
    Personally, I use Ultimate Cron β†’ , which allows me to work around the issue you mentioned by setting a broader schedule for the fast_404_generator cron (e.g., once an hour or even once a day), or even by disabling the cron on certain environments so that the HTML file is only regenerated when the cache is cleared.

  • πŸ‡ΊπŸ‡ΈUnited States jnicola

    I'm familiar with it.

    Unfortunately, you can't always utilize it. Whether it's the hosting services doesn't recommend it, or you've got uninformed obstinate devops team members who make you want to pull your hair out even though you shave your head...

    For those situations, a minimum lifetime is useful :)

Production build 0.71.5 2024