Skip to content

Conversation

@lubomir
Copy link
Contributor

@lubomir lubomir commented Nov 21, 2025

This PR optimizes network requests made by productmd:

  • Use HTTP HEAD requests instead of GET for file existence checks, avoiding unnecessary downloads
  • Add LRU caching (128 entries) to _file_exists() to prevent redundant network requests
  • Send proper HTTP headers: User-Agent: productmd/<VERSION> and Accept: application/json

The original code did a full GET request to download the entire file and
then threw the data away. Not great.

Assisted-By: Claude Code
If the same program wants to check the same path or url multiple times,
let's not repeat the possibly expensive HTTP request.

Assisted-By: Claude Code
The actual value can be overriden by any code using the library by
setting `productmd.common.USER_AGENT`.

Assisted-By: Claude Code
We are only interested in JSON, we can as well tell the server about it.

Assisted-By: Claude Code
@hlin
Copy link
Contributor

hlin commented Nov 24, 2025

LGTM.

@lubomir lubomir merged commit d49804e into release-engineering:master Nov 24, 2025
7 checks passed
@lubomir lubomir deleted the more-efficient-networking branch November 24, 2025 07:14
@richm
Copy link

richm commented Dec 5, 2025

please release this fix soon - linux-system-roles CI is broken due to this - see https://github.com/linux-system-roles/firewall/actions/runs/19936654882/job/57163293637?pr=310

@lubomir
Copy link
Contributor Author

lubomir commented Dec 8, 2025

The release is on PyPI for a while already. I made new Fedora builds though:
https://bodhi.fedoraproject.org/updates/FEDORA-2025-75d5e2c1ff
https://bodhi.fedoraproject.org/updates/FEDORA-2025-3e27b7b820

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants