Wednesday, 10 October 2018

How to stop caching my HTTP request & response in ionic 3

I want to stop caching my API request and response which native-http plugin stored its cache and its creating issue with my app.

All time API works fine but when I get 404 or 401 error from server it will cache it in my app and than after all time I will get timeout error with 1 status.

To overcome this issue I need to uninstall app and reinstall it again will work as expected.

Any Idea How to stop caching HTTP request and response ?

Or how to resolve issue of timeout with 1 status ?

I have tried below things in my request header but still no success.

self.httpPlugin.setHeader('*', 'authorization', 'Bearer ' + token);
self.httpPlugin.setHeader('*', 'Cache-control', 'no-cache');
self.httpPlugin.setHeader('*', 'Cache-control', 'no-store');
self.httpPlugin.setHeader('*', 'Expires', '0');
self.httpPlugin.setHeader('*', 'Pragma', 'no-cache');

Also added dummy uniq param in my request to make uniq request of my API call like below.

self.httpPlugin.setHeader('*', 'ExtraDate', new Date().toString());

Any one facing this kind of issue in ionic 3 ?

Tried this thread suggestions but no luck at all.

Suggest any solution for this issue.



from How to stop caching my HTTP request & response in ionic 3

No comments:

Post a Comment