How to empty cache for WebView? - iphone

I have a Webview that must load an image! When I upload this image I see every time the same image as before, and i must reboot my app to see the new image...
I think is a cache problem..How can I solve that??

One quick and easy method would be to append the current time stamp onto the url whenever you load it.
So instead of loading:
http://www.myhost.com/myimg.jpg
you'd load
http://www.myhost.com/myimg.jpg?12345689
Using a cache breaker like this is a very common method in web development to force reloading of content.
I did do some quick googling and it appears clearing out NSURL's cache won't do the trick. In 10.6 the api reloadFromOrigin: may do the trick, but I'm not aware if this has made it's way onto the iphone yet.
Edit:
I found this page in the docs. It looks like you can use the preferences system to say whether or not to use caching. Not tested, but that'd be something to look at.

Related

reuse result of initialize method from video_player flutter package

Is there option to reuse result of initialize method for video_player package? It takes time for complete - it would be great to cache it (eg. memory level) and reuse it when you back to before used video - and simple use cached data instead of wait for initialize result. I need it for intensive switching between videos.
There is a package called cached_video_player which may help resolve your problem. Check it out here.
I think you are asking about having the screen/page/widget pre-render. That is not currently supported by flutter according to this issue filed on github:
https://github.com/flutter/uxr/issues/6#issuecomment-881918751
Sure, but this is not very scalable and will quickly turn into a mess. It's much simpler and more flexible to just give MyRoute someway it can cache the next route, and then show that cached route when it needs. But flutter doesn't support this as everything needs to be 'on-stage' before it can be initialized. In AIR, or Unity, I could simply construct my new page, and it would begin loading data, I could then toss it on stage whenever I want.
PS. You probably already know you can pre-cache the video data/file itself.

How to clear/invalidate ambient cache on iOS app

When I update tilesets on mapbox, changes don't appear in the iOS app unless I re-install it. There is seemingly documentation on this here: https://docs.mapbox.com/ios/api/maps/5.2.0/Classes/MGLOfflineStorage.html#/c:objc(cs)MGLOfflineStorage(im)setMaximumAmbientCacheSize:withCompletionHandler: but I can't figure out how exactly to implement it. I don't have an MGLOfflineStorage object because I am not worried about offline map storage right now, I just want to refresh the cache in the app. There are good examples of how to do this in android, but not on iOS. Any help is appreciated (preferably in swift)
It appears to be correct to call the methods on the shared MGLOfflineStorage object. The method parameter should be a closure containing any code you want to execute upon completion.
MGLOfflineStorage.shared.invalidateAmbientCache { error in
print("Invalidated")
}
Naturally you should check the error in the usual 'safe' way.

Too much storage in IndexedDB using GunDB

I try to synchronize VR scene using GunDB.
In order to experiment it, I put a few data in GunDB.
But I got this warning.
storage warning
I use IndexedDB, and I can keep going it with hitting 'allow'
But I'm wondering why it uses too much storage!!!!!
setInterval(putLocation, Math.ceil(1000 / 50));
// putLocation
obj.get('attributes').get('position').put(object.attributes.position);
It updates data every 200ms in the same node. (object.attributes.position)
please let me know how could I fix it.
Thank you.
#huhsame 1.2GB for VR scene data? That seems suspicious.
By chance is this in Safari?
Safari has a known bug (#go1dfish found this) where it creates run-away storage accumulation (with or without gunDB) that gets triggered if its file descriptor is left open too long.
Could you see if the same thing happens in Chrome? If it does, it is a GUN bug then.
If it is just Safari, we tried to add code that would reset/reopen Safari's IndexedDB instance every 15 seconds, and have had success so far with that approach.
However, clearly, either Safari has changed something, or that workaround is no longer viable, so we'll need to figure something new out.
I understand Safari is very important because of iOS, it is just unfortunate that Safari lags behind on several very serious and important fronts (WebRTC, IndexedDB, & WebM). There is only so much our team can do to work around these bugs until Safari is more standards compliant. But where we can workaround, we will.
#marknadal
thanks for your answer.
and sorry I am late.
I tested it on Chrome and Safari after clearing storage.
after 30 minutes, Chrome used about
1MB,
and on the Safari, I did not find the usage panel but there is no pop-up for warning like the previous one.
I guess it was total data since September when I had started this experiment.
but it's just my opinion.
And I am still wondering that users should delete data in WebStorage regularly?
please answer me.

How to disable caching in Mojolicious::Lite app

currently i added this line to Mojolicious::Lite app to disable caching
app->renderer->cache->max_keys(0);
but sometimes webpage showing updated content and sometimes showing cached template
i do not know exactly what the problem is, there is no problem with morbo, this is happening only with hypnotoad. i want to try disabling the cache.
edit: i solved my problem. problem is not with the mojolicious caching, it is with the database caching. if you experience similar problem, try setting 'AutoCommit' to 1 in your DBI->connect() method.

iOS - Caching and loading images asynchronously

I want an image loading and caching library for iOS that
loads images asynchronously,
caches images, with a configurable cache size and LRU behaviour,
checks to see if images have been updated, using HTTP HEAD,
doesn't cache anything in the event of an error code or an invalid image.
I've looked at HJCache, but it only satisfies the first two of these criteria. Is there something better?
I know that this thread has been answered, but I have tried a library that has worked great. I was using ASIHttpRequest before and the difference is big.
https://github.com/rs/SDWebImage
Also, if someone needs to Resize or Crop the remote images, and have the same features that SDWebImage provide, I have integrated SDWebImage library with UIImage+Resize library (by Trevor Harmon), and created an example project. I modified the code of SDWebImage to deal with transformations (crop, resize).
The project is public on https://github.com/toptierlabs/ImageCacheResize. Feel free to use it!
EDIT : ASI has been deprecated now but #Tony's answer has a link to a library that seems to do most of this (disclaimer - I've not yet tried it and am going by #Tony's recommendation!)
ASIHTTPRequest does all of that :)
All you would have to do is add something like to the success callback
UIImage *image = [UIImage imageWithData:[request responseData]];
// If the image is nil ASIHTTPRequest will let you remove the data from the cache
// but I can't remember off the top of my head how. Checkout the docs!
EDIT
And when you've finished it, you could always pop it onto github for the rest of us . . .
I had a look recently for the sort of thing you describe -- either a general data cache, or an image centric one -- and didn't find much of interest. So you may have to roll your own to get all those features.
There's a various blogs posts and things detailing such things, such as
http://davidgolightly.blogspot.com/2009/02/asynchronous-image-caching-with-iphone.html.
I take it you've considered the Three20 library? I don't think it would cover your requirements though.