arthurfiorette / axios-cache-interceptor

📬 Small and efficient cache interceptor for axios. Etag, Cache-Control, TTL, HTTP headers and more!
https://axios-cache-interceptor.js.org
MIT License
703 stars 58 forks source link

Prevent caching private responses server-side #834

Open edwinveldhuizen opened 6 months ago

edwinveldhuizen commented 6 months ago

When a server returns private in the cache-control header, you do not want to cache it unless on a private device like a browser.

codecov[bot] commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.26%. Comparing base (f0ba5ad) to head (dc0443b). Report is 12 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #834 +/- ## ======================================= Coverage 99.26% 99.26% ======================================= Files 19 19 Lines 2442 2448 +6 Branches 212 211 -1 ======================================= + Hits 2424 2430 +6 Misses 17 17 Partials 1 1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

arthurfiorette commented 6 months ago

I'm not sure if a typeof window === 'undefined' check is the correct one in this case. It also works on native apps? What about personal nodejs projects? There are infinite use cases here that aren't covered just by checking if windows is defined.

edwinveldhuizen commented 6 months ago

I'm not sure if a typeof window === 'undefined' check is the correct one in this case. It also works on native apps? What about personal nodejs projects? There are infinite use cases here that aren't covered just by checking if windows is defined.

Good point about apps! What would you suggest as an alternative? A config option called “allowPrivate”?

arthurfiorette commented 6 months ago

Good point about apps! What would you suggest as an alternative? A config option called “allowPrivate”?

Seems fine! Default it to false to keep the previous behavior and add it do our docs.

arthurfiorette commented 3 months ago

Hi @edwinveldhuizen just quick follow up here, do you still need this feature?