Skip to content

Add optional X/Twitter GraphQL URL normalization for faster loading and better cache efficiency #16

@barzamini

Description

@barzamini

Hi, thank you for this awesome Rust port.

I wanted to suggest a small optimization originally shared by the Persian community for the Python MasterHttpRelayVPN project, and it may be useful here in the Rust version as an optional feature.

Background / Credit

This idea was shared publicly by seramo_ir and later adapted by users for the Python proxy_server.py version.

Source references:

What it does

For some X / Twitter GraphQL requests, the URL contains many extra query parameters.
Those changing parameters may reduce cache hits and increase repeated relay fetches.

The Python patch trims extra params and keeps only the first variables= section for matching requests.

Example concept:

if host == "x.com" and re.match(r"/i/api/graphql/[^/]+/[^?]+\?variables=", path):
    path = path.split("&")[0]

Why it may help

  • Faster X/Twitter loading
  • Better cache reuse
  • Less repeated Apps Script requests
  • Lower bandwidth / quota usage
  • Better experience on slow networks

Rust equivalent idea

Somewhere in request normalization / URL preprocessing stage:

if host == "x.com"
    && path.starts_with("/i/api/graphql/")
    && path.contains("?variables=")
{
    if let Some(pos) = path.find('&') {
        path.truncate(pos);
    }
}

Suggested implementation

Maybe add it as:

  • enabled by default only for x.com
    or
  • optional config flag such as:
{
  "normalize_x_graphql": true
}

Important note

This is not my original idea.
The concept comes from the community Python patch mentioned above. I’m only suggesting possible Rust integration for this project.

Thanks again for the excellent project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions