Search code examples
flutterdartcaching

Get file content from URL returned old content


I read a text file content from an URL and it is working perfectly like below:

response = await http.get('http://example.com/complex.txt'));

  if (response.statusCode == 200) {
    complex = (convert.json.decode(response.body)['data'] as List)
        .map((e) => Complexes.fromJson(e))
        .toList();

    for (var i in complex) {
      complexes.add(i);
    }
  }

But when I change text file content, body of response does not change and show old content.

Questions:

  1. Is text caching in host or application?

  2. How can I disable this caching?


Solution

  • I solved my problem with fake parameter like below :

    response = await http.get('http://example.com/complex.txt?parameter=1'));
    

    I do not think it is the best solution but it is solved my problem.