If my native iOS app has a webview, where are the files of the page I'm browsing stored?

Hi, I think I never thought about this but... let's say I have my iOS app (swift) and I have a ViewController with a WKWebView. If I open a link of a page with a pdf, where are the pdf and that page's files stored? Is there a way to clean the directory in which those files get stored? Is it something I shouldn't worry about?

Thanks in advance

Answered by DTS Engineer in 713321022

where are the pdf and that page's files stored?

That’s not documented.

Is there a way to clean the directory in which those files get stored?

There’s no single directory to clear here, but there is an API to see what data is stored and to clear it. Check out the WKWebsiteDataStore type.

Is it something I shouldn't worry about?

It’s hard to say. Do you have a specific concern?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

where are the pdf and that page's files stored?

That’s not documented.

Is there a way to clean the directory in which those files get stored?

There’s no single directory to clear here, but there is an API to see what data is stored and to clear it. Check out the WKWebsiteDataStore type.

Is it something I shouldn't worry about?

It’s hard to say. Do you have a specific concern?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Are you specifically talking about cache files? Or something else?

Apple manages the cache files. Your app wouldn't be able to directly access them. But that WKWebsiteDataStore class should do what you want.

But if you are talking about something else, then you have other options. If these are your own files you want to view in a web view, then you could include them in your app's resources and access them from there. Or you could create them in a temporary directory and view them there. You can also generate them entirely in RAM without needing to have any files on disk. Note that Apple may still cache that data to cache files, even if they didn't originally exist on disk.

If my native iOS app has a webview, where are the files of the page I'm browsing stored?
 
 
Q