I hit #2881045: Add/remove sessionless requests only which for my use case I really need that not happening. The proposed solution there was a bit arbitrary. I know it's a setting, but it addressed only the session part and although it might work most of the time, there might be use cases where the session is there but you still might be a cacheable response.

I also sensed that there's never a proper expiry of the url from the registry, which might make sense to have it.

I am proposing a different approach with the following modifications:

- Add an expire column to the registry as well as a configuration for it. It defaults to 0, same behavior as before. Patch includes update hooks for both the config and the table.
- Do not clear the registry when max age is < 1 and when the response is 200: Leave it as not to registered, but not remove it.
- Adds a cron entry to remove expired entries, if configured.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

hanoii created an issue. See original summary.

hanoii’s picture

Status: Active » Needs review
StatusFileSize
new8.85 KB

Attached is the patch for this.

hanoii’s picture

StatusFileSize
new9.01 KB

Forgot an use statement on the install file/

hanoii’s picture

StatusFileSize
new9.01 KB
new852 bytes

Set the current db items to -1 so they are not automatically expired, which is the default. Any change on this setting will slowly change the registry.

lisa.rae’s picture

Status: Needs review » Needs work

Marking needs work, patch failed to apply

hanoii’s picture

Status: Needs work » Needs review
StatusFileSize
new9.32 KB

Attached is a re-rolled patch against 1.0.

Bear in mind that I am changing the dependency pattern into a setter injection, instead of constructor so that this module doesn;t have to play catch up with parent dependencies but only add what it needs.

hanoii’s picture

StatusFileSize
new9.3 KB

Previous patch has an error due to the re-roll.

hanoii’s picture

hanoii’s picture

StatusFileSize
new9.21 KB

Another quick fix to the patch.

hanoii’s picture

Hiding patch, work is now on the fork/MR.

szato made their first commit to this issue’s fork.

szato’s picture

Rebased MR and added 2 extra commits:

  • 30cb67ca - Added 1 hour; 3,6,9,12 hours; 1 day; 1 weeks.
  • 12a436fb - Phpcs fixes.
ericgsmith’s picture

Status: Needs review » Needs work

I think this is something that the module should be doing and the approach looks sensible to me - thank you.

I looks like an unintended change was introduced that broke the tests - I think we will also need more test coverage that the expiration is working.

ericgsmith’s picture

Have fixed the existing test and taken a closer look.

I think we need to be mindful here for pages using the internal page cache module.

The behaviour for page_cache is permanent by default:

    // The response passes all of the above checks, so cache it. Page cache
    // entries default to Cache::PERMANENT since they will be expired via cache
    // tags locally. Because of this, page cache ignores max age.

While some setups will have the internal page cache disabled and rely only on an external page cache, not all will.

If page cache is enabled, it looks like the url registry item is removed after expiration, but as the page cache entry is permanent it will remain and continue to be returned by Drupal this never gets added back to the registry because of:

    // When page_cache is enabled, skip HITs to prevent running code twice.
    if ($cached = $response->headers->get('X-Drupal-Cache')) {
      if ($cached === 'HIT') {
        return FALSE;
      }
    }

I haven't thought too much on this - perhaps we can just return TRUE here? We don't introduce anything negative for sites without page cache, as the response won't have that header.

ericgsmith’s picture

Will need a rebase after #2912139: Logged-in requests remove items from traffic registry comitted.

While that related issue is committed I am still keen on this idea as a solution.