Add passthrough query setting per redirect

Created on 21 November 2024, about 1 month ago

Problem/Motivation

The redirect setting "Retain query string through redirect." works perfectly when enabled for the redirects to forward the query parameters to the destination. However, it has a minute issue. A new page cache entry is created for each set of query parameters. This is fine for sites with fewer number of redirects. However, if the number is huge, this could increase the cache size a lot.

Steps to reproduce

  • Truncate the cache_page database table.
  • Ensure that the "Retain query string through redirect." setting at /admin/config/search/redirect/settings
  • Create a new redirect from "foo" to "/bar"
  • As an anonymous user visit "/foo". You should redirected to "/bar" (ignore the 404 error if it occurs).
  • Check the cache_page table. You should see two entries - one for the redirect itself and the other for the redirected path.
  • Visit "/foo?query=baz". You should be redirected to "/bar?query=baz".
  • Check the cache_page table again. There should be two additional entries.

Proposed resolution

In addition to the global setting, there should be a setting "per redirect" to retain the query parameters. So, instead of the behavior being global, it would be great to have it on redirect add/edit form. Of course, we only show that option if the global option is disabled.

Remaining tasks

MR and review

User interface changes

A new option is added to the Redirect add/edit form.

API changes

NA

Data model changes

An extra column gets added due to the new field.

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇮🇳India ajits India

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

Merge Requests

Comments & Activities

  • Issue created by @ajits
  • 🇮🇳India ajits India

    I am working on creating a MR.

  • 🇮🇳India ajits India

    Let's see how the tests fare. Also, this will need some tests.

  • Pipeline finished with Success
    about 1 month ago
    Total: 187s
    #346108
  • Pipeline finished with Failed
    27 days ago
    Total: 172s
    #349360
  • Pipeline finished with Failed
    27 days ago
    Total: 1849s
    #349391
  • Pipeline finished with Failed
    27 days ago
    Total: 186s
    #349437
  • Pipeline finished with Success
    27 days ago
    Total: 183s
    #349454
  • 🇮🇳India ajits India

    Addressed feedback and adjusted tests. This is ready for review.

  • Pipeline finished with Success
    27 days ago
    Total: 183s
    #349462
  • Pipeline finished with Success
    26 days ago
    Total: 258s
    #350569
  • 🇮🇳India ajits India

    I received feedback from Alec → about the changing behavior of the public function findMatchingRedirect in the redirect.repository service. I have adjusted the code to preserve the current functionality; and adjusted to the newly provided field. Also, adjusted the tests to be more detailed.

  • Pipeline finished with Success
    25 days ago
    Total: 287s
    #351580
  • Pipeline finished with Success
    25 days ago
    Total: 177s
    #352111
  • Pipeline finished with Success
    25 days ago
    Total: 177s
    #352118
  • Pipeline finished with Success
    24 days ago
    Total: 210s
    #352970
  • 🇸🇮Slovenia alecsmrekar

    Looks great, thank you!

Production build 0.71.5 2024