Android WebView cache not expiring

in my android app I am using WebView and faced caching issue. After caching the file, the WebView just keeps it forever (or at least until I manually delete the cache).

In the Apache Access-Log, I see that the WebView does not send requests after the file has been cached. How can I configure WebView to send validation requests if a file has expired using generic ETags and a 304 HTTP code? In desktop browser (Firefox, Chrome), caching works as expected.

Here is my code:

    webView = (WebView) findViewById(R.id.webView);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setDomStorageEnabled(true);
    webView.setWebViewClient(new EWebViewClient(this));
    webView.getSettings().setBuiltInZoomControls(false);
    webView.getSettings().setSupportZoom(true);
    webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
    webView.setWebChromeClient(new EWebChromeClient(this));
    webView.setBackgroundColor(Color.argb(1,0,0,0));
    webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    webView.loadUrl(url);

      

EWebViewClient only overwrites: "shouldOverrideUrlLoading, onPageFinished, onLoadResource, onReceivedError"

I really appreciate any help you can provide.

+3


source to share





All Articles