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

Question: does it works for streaming requests ? #767

Closed quentin-desbin closed 10 months ago

quentin-desbin commented 10 months ago

What happened?

It's just a question and maybe a bug.

I use axios to perform a request to my server, but my server returns an StreamingResponseBody (SpringJava), it means that the server will always returns a 200 directly, but the content is an outputstream written "asynchronously".

When using axios and axios-cache-interceptor, the answer saved in cache is empty.

It's recommended to use StreamingResponseBody when manipulating heave multiple assets (blob of images,files, etc.) but i'm not sure it's easily compatible in this case. What do you think about this ?

Thanks !

axios-cache-interceptor version

1.4.1

Node / Browser Version

Chrome 20.0.6099.12

Axios Version

1.6.5

What storage is being used

Web Storage

Relevant debugging log output

N/A
arthurfiorette commented 10 months ago

Hey @quentin-desbin i'm not sure if streams are supported. Probably you will need to add a response interceptor before the axios cache interceptor one to collect the entire stream into a data format it can handle like string or object.

https://github.com/arthurfiorette/axios-cache-interceptor/pull/775 may also help too.

arthurfiorette commented 10 months ago

https://axios-cache-interceptor.js.org/guide/interceptors#streams-and-non-json