This project is a Ktor client caching, which is (almost) literally a port of FileStorage but for KMP based on OKIO and kotlinx serialization.
Web targets are using an SQL database from SQLDelight to persist the cache.
private val publicStorageCaching = KtorFileCaching()
HttpClient {
install(HttpCache) {
publicStorage(publicStorageCaching)
}
}// {project}/build.gradle.kts - Browser Js
jsMain.dependencies {
implementation("io.github.frankois944:ktorfilecaching-jsbrowser:0.9.0")
implementation(devNpm("copy-webpack-plugin", "9.1.0"))
}
// OR
// {project}/build.gradle.kts - Wasm JS
wasmJsMain.dependencies {
implementation("io.github.frankois944:ktorfilecaching:0.9.0")
implementation(devNpm("copy-webpack-plugin", "9.1.0"))
}- Update or Create your webpack folder
// {project}/webpack.config.d/sqljs.js
config.resolve = {
fallback: {
fs: false,
path: false,
crypto: false,
}
};
const CopyWebpackPlugin = require('copy-webpack-plugin');
config.plugins.push(
new CopyWebpackPlugin({
patterns: [
'../../node_modules/sql.js/dist/sql-wasm.wasm'
]
})
More info on SQLDelight documentation
implementation("io.github.frankois944:ktorfilecaching-jsnode:0.9.0")implementation("io.github.frankois944:ktorfilecaching:0.9.0")The current supported targets are :
| Target | Supported |
|---|---|
| jvm | ✅ |
| js Node | ✅ |
| js browser | ✅ |
| wasmJS | ✅ |
| iosX64 | ✅ |
| iosArm64 | ✅ |
| iosSimulatorArm64 | ✅ |
| macosX64 | ✅ |
| macosArm64 | ✅ |
| watchosArm32 | ✅ |
| watchosArm64 | ✅ |
| watchosSimulatorArm64 | ✅ |
| watchosX64 | ✅ |
| tvosSimulatorArm64 | ✅ |
| tvosX64 | ✅ |
| mingwX64 | ✅ |
| mingwX64 | ✅ |
| linuxX64 | ✅ |
| linuxArm64 | ✅ |