Skip to content

Invalidation logic for caching of MB search API responses #218

@arsinclair

Description

@arsinclair

I know cache invalidation is a hard problem 🥲. But, it's an annoying one.

When augmenting a musicbrainz release with a barcode and then trying to search for that barcode in Harmony, it returns

MusicBrainz: API returned no results: https://musicbrainz.org/ws/2/release?query=barcode%3A853567576415&fmt=json

At first the MB API returns {"created":"2026-05-10T02:25:10.167Z","count":0,"offset":0,"releases":[]}, however within minutes MusicBrainz API starts to return the correct data. Harmony in turn keeps thinking that the data doesn't change because it had cached that request somewhere and for hours there's no way to process a release.

There needs to be some kind of invalidation mechanism: manual button (force refresh), a background query to MusicBrainz with 304 not modified response, a very small expiration date on caches for the releases imported within minutes/hours from the current datetime (as changes are expected, so it is not useful to cache), etc. Maybe folks have some better ideas.

Metadata

Metadata

Assignees

No one assigned

    Labels

    metaRefactoring, tests and other tasks

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions