mjftw / react-bitbucket-pull-request-board

React and Redux based project to show the status and activity of all your Bitbucket pull requests in an info board.
MIT License
1 stars 1 forks source link

Cache fetch results to reduce external traffic #21

Open mjftw opened 4 years ago

mjftw commented 4 years ago

Currently any time data is needed, a request is sent. Oftentimes an identical request has recently been made and if the data from this was cached, this cache could be used instead to prevent unnecessary traffic. Since we want the data to remain more or less live we will need to make identical requests so can't keep the cache forever. Since the minimum data refresh time is 1 minute, this would be a suitable length to keep any cached request responses.

Pseudocode:

makeRequest:
    if requestIsCached and requestAgeMinsLessThan(1):
        return cachedResult
    else:
        makeTheRequest()
mjftw commented 4 years ago

Should be relatively easy to implement with: https://www.npmjs.com/package/axios-cache-adapter