zyra / ionic-image-loader

Ionic 2+ Component that loads images in a background thread and caches them for later use
MIT License
435 stars 137 forks source link

cache not working on both iOS and Android devices #203

Closed xinfengmich closed 6 years ago

xinfengmich commented 6 years ago

I tried to use Ionic Image loader to load google street view images in order to reduce the requests to Google. I set cache time to 30 days as imageLoaderConfig.setMaximumCacheAge(30 24 60 60 1000);

After more that one day ( since google street view images HTTP caching 1 day by default ), turned on 'Airplane Mode' on both Android and iOS devices, then tried to view the image that I viewed before. The image wasn't loading, looked like still sending the http request to Google and not loading the image from local cache.

Any help would be appreciated.

xinfengmich commented 6 years ago

Use "ionic-image-loader": "6.3.0", "@ionic-native/file": "4.13.0", "cordova-plugin-file": "6.0.1",

Ross-Rawlins commented 6 years ago

I followed your steps and its still failing for me it says it cant access the path. When I look at the path it has both localhost and file:// in it.

xinfengmich commented 6 years ago

On iOS, it looked like
background-image: url(http://localhost:8080/var/mobile/Containers/Data/Application/0ADF9302-E587-403A-91F0-1AE57FBE6658/Library/Caches/image-loader-cache/2023760148); background-repeat: no-repeat no-repeat;"> On Android, it looked like background-image: url("file:///data/user/0/edu.umich.mobile.MichTDev/cache/image-loader-cache/1420132908");

I'm upgrading "ionic-image-loader" to the latest version 6.3.2 and see if it will fix my problem.

Ross-Rawlins commented 6 years ago

Its working for me on some project but on others its producing a weird caching URL but I am not sure where the issue is.

Ross-Rawlins commented 6 years ago

So after further investigation the working app gets a path of file:///data/user/0/myApp/cache/image-loader-cache/1046963097

but the broken app returns a path like this http://localhost:8080/_file_/data/user/0/bundleID/cache/image-loader-cache/1088978943

this is only on android on a new project.

Ross-Rawlins commented 6 years ago

Looks to be a webview issue.

tnovau commented 6 years ago

Yes, I'm facing the same issue here. Please let me know if you can solve it

rubennavarroc commented 6 years ago

Hello, with the newest ionic webview it should give you a transformed url, which is wrong anyway because of a webview bug. Try using base64 image instead.

Ross-Rawlins commented 6 years ago

@rubennavarroc the webview guys are saying there is no reported issue with them. And if you convert the image to a base64 when do you do this? Do you do it to what ever path is give to the image? can you give us a snippet?

tnovau commented 6 years ago

Thanks @rubennavarroc I changed to base64 and it's working smooth.

xinfengmich commented 6 years ago

"ionic-image-loader" version 6.3.2 worked for me.

pcsantana commented 5 years ago

@Ross-Rawlins did you get it to work?

I'm facing the same problem after update to ionic webview 2.x. I saw the workaround to convert to base64, but if possible I would like to use file uri.

Thank you.

xinfengmich commented 5 years ago

I have the same issue when updating to ionic webview 2.x. See https://github.com/zyra/ionic-image-loader/issues/206 I get google street view images which no file extension in the URL, with "cordova-plugin-ionic-webview": "2.3.1", it can't load on Android device.