Flutter Chopper library cache http response

709 views Asked by At

in my mobile application i'm using Chopper http library and i would like to cache http response with this library, my server return this headers with responses:

<-- 200 http://www.www.www/api/v1/dashboard/allData
content-type: application/json
cache-control: max-age=600, private
transfer-encoding: chunked
date: Mon, 07 Sep 2020 05:47:00 GMT
server: Apache

i added this interceptor to chopper interceptors:

final client = ChopperClient(

client: http.IOClient(
  HttpClient()..connectionTimeout = const Duration(seconds: 60),
),
baseUrl: webUri,
services: [
  _$WebApi(),
],
converter: const JsonConverter(),
interceptors: [
  const HeadersInterceptor({'Content-Type': 'application/json','Cache-Control':'private, max-age=600'}),
  HttpLoggingInterceptor(),
]);

now i expect cache work fine for my application, this solution is correct?

0

There are 0 answers