0

在我的移动应用程序中,我正在使用Chopper http库,我想用这个库缓存 http 响应,我的服务器返回这个带有响应的标头:

<-- 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

我将此拦截器添加到chopper拦截器中:

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(),
]);

现在我希望缓存对我的应用程序正常工作,这个解决方案是否正确?

4

0 回答 0