Skip to content

private-api: make pro-members / announcements / post-tips browser-cacheable and stop over-fetching #1272

Description

@feruzm

Three private-api queries in the SDK refetch far more often than their data actually changes, and none of their responses can be reused by the browser between page loads. All three are global or per-post reads with no per-user component, so most of that traffic is avoidable.

Current state

query file issue
pro-members packages/sdk/src/modules/accounts/queries/get-pro-members-query-options.ts staleTime 5 min on a roster the comment itself describes as "changes slowly"
announcements packages/sdk/src/modules/notifications/queries/get-announcements-query-options.ts staleTime is a sensible 1 h, but a cold cache on every fresh page load still refetches
post-tips packages/sdk/src/modules/posts/queries/get-post-tips-query-options.ts POST for a read, and no staleTime (defaults to 0, so it is stale on every mount/refocus)

post-tips is the structural one: because it is a POST with a JSON body, the response is uncacheable by the browser and by any intermediary, permanently. It takes author + permlink and returns tips for that post - a plain read.

Proposed

  1. post-tips -> GET with author/permlink as query params, plus a staleTime. Needs a companion endpoint change in the private-api service; keep the POST accepted until clients have rolled.
  2. pro-members -> raise staleTime to ~30-60 min. Nothing about a badge roster needs 5-minute freshness.
  3. All three -> have the endpoints send Cache-Control: public, max-age=..., stale-while-revalidate=.... These payloads are identical for every visitor and need no auth, so the browser should be able to reuse them across page loads instead of re-requesting on each navigation.

staleTime alone only dedupes within one session; the Cache-Control part is what stops the repeat request on the next page load. Both are needed.

Notes

  • SDK change ships first, then the web bump - see the usual release order.
  • Worth checking whether mobile calls the same three endpoints before changing the post-tips verb.

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