Tuesday, January 23, 2018

#1 2012-08-02 11:17:10 am

Registered: 2005-07-03
Posts: 125

Web View Quandry - Prefer "Live" version over "Cached" version


I am updating an AppleScript Studio (probably for the last time) and would like to include a web view, or webview.

So I added the following code:


on urlGet()
   set theURL to "[url]http://accounts.myserver.com/~[/url]" & myid & "/Updates/myimage.jpg" as text
           set newString to (call method "stringByAddingPercentEscapesUsingEncoding:" of theURL with parameter 30)
           set URLWithString to call method "URLWithString:" of class "NSURL" with parameter newString
           set requestWithURL to call method "requestWithURL:" of class "NSURLRequest" with parameter URLWithString
           set mainFrame to call method "mainFrame" of webView
           call method "loadRequest:" of mainFrame with parameter requestWithURL
   on error theError
   end try
end urlGet

This works very well, except that if the image is changed on the server, the web view will always display the cached copy located in ~/Library/Caches/com.mycompany.myapp/Cache.db

If I manually clear the cache, the image updates properly

How do I change my code so that it prefers the "live" copy to the cached copy, unless, of course, the server is unreachable?

Last edited by deanshavit (2012-08-02 11:31:16 am)



#2 2012-08-02 05:58:56 pm

Shane Stanley
From:: Australia
Registered: 2002-12-07
Posts: 5231

Re: Web View Quandry - Prefer "Live" version over "Cached" version

I can't help with your ASStudio code, but you're calling +requestWithURL:, and you need to call +requestWithURL:cachePolicy:timeoutInterval:. The cachePolicy parameter is the key for what you want.

Shane Stanley <sstanley@myriad-com.com.au>



Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)