locked
Intercept webview requests

    Question

  • Hello,

    I am building a Windows Store App with a webview control. 

    My app needs to provide a custom caching policy to the webview, serving up local content as necessary. 

    1) Is it possible to intercept each request that is made by the webview while loading a page (all css, javascript, images etc) and serve it locally (similar to Android webview shouldInterceptRequest)?

    2) Can a custom caching policy be specified for the webview? 

    Thanks in advance

    Ash

    Friday, April 4, 2014 1:22 AM

Answers

  • 1) I think you want DOMContentLoaded - you can parse the HTML and decide if you want to load local content.  However, there's no built-in function to make this easy.

    2) No. However, once WebView caches something in its InetCache, and if that content has no expiration, that content will *always* be served from cache.  The catch on this is that if the content changes, you have to manually delete the cache.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.


    Friday, April 4, 2014 12:13 PM
    Moderator