How to make Android WebView clear cache?
<p>Here is my scenario. I am using WebView to show my mobile-ready website inside an app. We regularly update our website and automatically clear our website cache, so visitors get the latest version of our website instead of stale versions. I've noticed that sometimes WebView is serving old content -- it sometimes doesn't load newer versions of our website. Hence, I'm looking for a way to force WebView to show new content.</p>

<p>I know I could totally disable WebView cache and force it to grab the page from our server every time, but that is inefficient. I want the cache used when the cached page is the latest version; if it isn't, then the cache should not be used.</p>

<p>The only way I can think of doing this is by manually clearing the cache, something like this:</p>

<pre><code>@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    view.clearCache(true);
}
</code></pre>

<p>But, again, this is inefficient -- there is no need to clear the whole cache after each page view. My question is, is there any way to clear just cached HTML files and leave CSS / JS / etc.? This would be a nice compromise between always clearing the cache and sometime serving stale content. By removing just the cached HTML files after each page view, WebView is forced to grab the latest HTML pages from my server, without having to reload CSS or JS.</p>

<p>Better yet, to save wasting unnecessary processing power, is there a way to remove from cache only the specific page the user is on? E.g. After loading google.com, the cached HTML page for google.com (but not the CSS, JS, etc.) is removed so that the next time google.com is loaded, the latest version is grabbed.</p>

<p>Thanks!</p>