Optimizations

pull/653/merge
Varun Patil 2023-05-14 21:56:41 -07:00
parent 3fb17c0450
commit e8c59d7648
2 changed files with 13 additions and 2 deletions

View File

@ -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
}

View File

@ -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) {