Android.Net.Uri change caching time

2019-08-22 05:46发布

问题:

How can I change caching time? I receive a notification when the PDF file is updated on the server. I get the same link, but with another (previous) document. Since URL hashes the previous document, it opens the old one, not the updated one.

Android.Net.Uri uri = Android.Net.Uri.Parse(url);
Intent browserIntent = new Intent(Intent.ActionView, uri);
try {
  context.StartActivity(browserIntent);
}
catch (ActivityNotFoundException e) {
  Console.WriteLine(e);
  Toast.MakeText(context, "Install PDF reader", ToastLength.Short);
}

My URL doesn't change, however, pdf file changes.

回答1:

I solved my problem, I just changed the URL. And now every URL to the pdf file is unique and not cached.

url = url.Replace(" ", "%20");
url = $"{url}?random_number={new Date().Time}";