Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disk cache doesn't work on iOS and Android #103

Closed
ilya-savinkov opened this issue May 6, 2024 · 4 comments
Closed

Disk cache doesn't work on iOS and Android #103

ilya-savinkov opened this issue May 6, 2024 · 4 comments

Comments

@ilya-savinkov
Copy link

Hello, I have next Kamel config

KamelConfig {
    takeFrom(KamelConfig.Default)
    svgCacheSize = 300

    httpFetcher {
        httpCache(DefaultHttpCacheSize)

        Logging {
            level = LogLevel.INFO
            logger = object : Logger {
                override fun log(message: String) {
                    Napier.d(
                        message = message,
                        tag = "kamel"
                    )
                }
            }
        }
    }
}

Here I have httpCache with DefaultHttpCacheSize. When I launch app my images download, but when I restart app my images download again.

---------------------------- PROCESS STARTED (13037) for package com.intellect.logos ----------------------------
2024-05-06 09:37:24.553  D  REQUEST: http://192.168.0.104:8080/image/US.svg
                            METHOD: HttpMethod(value=GET)
2024-05-06 09:37:24.554  D  REQUEST: http://192.168.0.104:8080/image/EU.svg
                            METHOD: HttpMethod(value=GET)
2024-05-06 09:37:24.789  D  RESPONSE: 200 OK
                            METHOD: HttpMethod(value=GET)
                            FROM: http://192.168.0.104:8080/image/EU.svg
2024-05-06 09:37:24.794  D  RESPONSE: 200 OK
                            METHOD: HttpMethod(value=GET)
                            FROM: http://192.168.0.104:8080/image/US.svg
---------------------------- PROCESS ENDED (13037) for package com.intellect.logos ----------------------------
---------------------------- PROCESS STARTED (13158) for package com.intellect.logos ----------------------------
2024-05-06 09:37:38.806  D  REQUEST: http://192.168.0.104:8080/image/US.svg
                            METHOD: HttpMethod(value=GET)
2024-05-06 09:37:38.810  D  REQUEST: http://192.168.0.104:8080/image/EU.svg
                            METHOD: HttpMethod(value=GET)
2024-05-06 09:37:38.921  D  RESPONSE: 200 OK
                            METHOD: HttpMethod(value=GET)
                            FROM: http://192.168.0.104:8080/image/US.svg
2024-05-06 09:37:38.925  D  RESPONSE: 200 OK
                            METHOD: HttpMethod(value=GET)
                            FROM: http://192.168.0.104:8080/image/EU.svg
@luca992
Copy link
Member

luca992 commented May 15, 2024

So we are actually using ktor's CacheStorage for caching images to the disk, meaning requests will probably still be shown in the logs.

Can you verify there is actually no data in your application's cache directory? I just tested on android & desktop and cached data is being retrieved from the disk cache. Loading cached images in airplane mode in the sample is working as expected on android.

I did find a bug where desktop doesn't work offline, but when online it is still loading images from the disk cache.

@luca992
Copy link
Member

luca992 commented May 15, 2024

I tested your logging setup. It does indeed log requests even if loading from the disk cache in airplane mode. If you don't like this behavior report it to ktor.

@luca992 luca992 closed this as completed May 15, 2024
@luca992
Copy link
Member

luca992 commented May 16, 2024

I tested ios offline, and it also errors before it tries to load from the diskcache. I'll have to look into that as well. It should be working fine while connected to the internet as well though

@luca992
Copy link
Member

luca992 commented May 16, 2024

If loading data while offline is what you're having an issue with follow #104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants