Skip to content

/snapshots api breaking change #365

@chreekat

Description

@chreekat

Fixing #355 introduced a breaking change that broke stack ls snapshots remote.

The root issue was that the new server was underpowered, and Stackage started locking up under load. One mitigation for that was to use Cloudflare as a CDN and cache pages. This helped a lot.

The next issue was that Cloudflare doesn't use the "Accept" HTTP header as part of its caching key. Routes that returned different data depending on that header -- /snapshots in particular -- started returning the "wrong" data 50% of the time. Whatever data got cached last -- JSON or HTML -- would be used for every request, regardless of Accept header.

The final issue was that I didn't announce my intentions more widely. I should have posted on Discourse about the potential change. I was a little burnt out at the time and didn't follow my own best practices.

So what changed exactly? In 10c9d83 I created a new, dedicated JSON endpoint at /api/v1/snapshots. The original /snapshots endpoint was changed to only return HTML.

How do we fix?

Well, I did enable other mitigations for the slower server. It should be fine to just turn off caching for that endpoint and start using the Accept header again.

This would be a temporary change. In the long run, I'd like to remove the Accept-varying response type. It seems much cleaner to have an actual versioned API for JSON data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions