Skip to content

Allow caching some API responses that change rarely - #1560

Merged
cpeel merged 1 commit into
DistributedProofreaders:masterfrom
cpeel:cache-some-api-responses
Dec 31, 2025
Merged

cpeel merged 1 commit into
DistributedProofreaders:masterfrom
cpeel:cache-some-api-responses

Conversation

@cpeel

@cpeel cpeel commented Dec 26, 2025

Copy link
Copy Markdown
Member

Allow the browser to cache some API responses for endpoints that change very very rarely. These in particular are used by the new PI and letting the browser cache them for a bit will make the initial PI load faster when users are coming in and out of the PI (the PI doesn't reload these when it moves between pages).

We cache the site documents and dictionaries for a day. Project pickersets for an hour.

Sandbox: https://www.pgdp.org/~cpeel/c.branch/cache-some-api-responses/

Testing is making sure the Cache-Control header is included in the response, eg:

export API_KEY=review
curl -i -H "Accept: application/json" -H "X-API-KEY: $API_KEY" \
    -X GET "https://www.pgdp.org/~cpeel/c.branch/cache-some-api-responses/api/v1/documents"

@cpeel
cpeel requested review from 70ray and srjfoo December 26, 2025 19:16
@cpeel cpeel self-assigned this Dec 26, 2025
@cpeel
cpeel merged commit 6077c2a into DistributedProofreaders:master Dec 31, 2025
9 checks passed
@cpeel
cpeel deleted the cache-some-api-responses branch December 31, 2025 02:10
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