Http and cache in Ionic 4

Hi !

CACHE ! I’ve got a cache when I call my API from my Ionic 4 app.
It’s not what I want because my values are updated in the backoffice but I still GET the old values in my ionic app (which is not the case in my php site : I see the new value)

I can’t find code to call the API with options (cache duration…) like in Ionic 3.
Do you have any idea ?

Ben

I would look into putting Cache-Control headers on the server side.

Thank you @rapropos ! :slight_smile:
As my request to the API receive the right answer by another way than mu ionic app, I thaught the clue is in the app (client side).
But I’ll try the server side anyway.

But still : how could we edit the client side headers of the request ? I can’t find a way for version 4 of ionic

** edit **
I confirm. I still have a cache for my mobile app with this server side header :
header(‘Access-Control-Max-Age: 0’);
header(‘Cache-Control: max-age=0’);
header(‘Cache-Control: s-maxage=0’);
header(‘Cache-Control: no-cache’);
header(‘Cache-Control: no-store’);


It can be done in an HttpInterceptor just like in any other Angular app.

OK Thank you !
I was gradually approaching this solution :wink:
Cheers !

Hi BBenard,

Can we do cache for socket data. can you please help me. I dont want to fetch for same data again and again by emiting or on. so help me please.