diff --git a/app/src/main/java/gallery/memories/NativeX.kt b/app/src/main/java/gallery/memories/NativeX.kt index b8f8ad7a..d3e9fdd3 100644 --- a/app/src/main/java/gallery/memories/NativeX.kt +++ b/app/src/main/java/gallery/memories/NativeX.kt @@ -72,10 +72,16 @@ import java.net.URLDecoder } // Allow CORS from all origins - response.responseHeaders = mapOf( + response.responseHeaders = mutableMapOf( "Access-Control-Allow-Origin" to "*", "Access-Control-Allow-Headers" to "*" ) + + // Cache image responses for 7 days + if (path.matches(API.IMAGE_PREVIEW) || path.matches(API.IMAGE_FULL)) { + response.responseHeaders["Cache-Control"] = "max-age=604800" + } + return response } diff --git a/app/src/main/java/gallery/memories/service/DbService.kt b/app/src/main/java/gallery/memories/service/DbService.kt index cc8b8075..8cd0df7a 100644 --- a/app/src/main/java/gallery/memories/service/DbService.kt +++ b/app/src/main/java/gallery/memories/service/DbService.kt @@ -4,7 +4,7 @@ import android.content.Context import android.database.sqlite.SQLiteOpenHelper import android.database.sqlite.SQLiteDatabase -class DbService(context: Context) : SQLiteOpenHelper(context, "memories", null, 26) { +class DbService(context: Context) : SQLiteOpenHelper(context, "memories", null, 27) { override fun onCreate(db: SQLiteDatabase) { db.execSQL(""" CREATE TABLE images ( @@ -18,6 +18,11 @@ class DbService(context: Context) : SQLiteOpenHelper(context, "memories", null, flag INTEGER ) """) + + // Add index on local_id, dayid, and flag + db.execSQL("CREATE INDEX images_local_id ON images (local_id)") + db.execSQL("CREATE INDEX images_dayid ON images (dayid)") + db.execSQL("CREATE INDEX images_flag ON images (flag)") } override fun onUpgrade(database: SQLiteDatabase, oldVersion: Int, newVersion: Int) {