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

swでAPIアクセスをキャッシュする #88

Open
totegamma opened this issue May 8, 2023 · 1 comment
Open

swでAPIアクセスをキャッシュする #88

totegamma opened this issue May 8, 2023 · 1 comment
Milestone

Comments

@totegamma
Copy link
Owner

totegamma commented May 8, 2023

今はセッションでしか持っていないので、ブラウザをリロードするたびに全てgetしている
messageやcharacterはほぼ変更ないので、(半)恒久ストレージに入れちゃってもいいかも?(indexeddbとかcachestorage?とか(よくわかってない))(自動でリテンションしてくれると便利ではある)

messageに関しては、それに紐づくassociationのリストは頻繁に変更があるのでそこは注意
また、characterは低頻度であれどプロフィール更新で変わるので、何かしらのcache invalidateの仕組みが必要

案1 websocketイベント
一番簡単だけどオフラインの人が更新できない。当然ボツ。

案2 messageにして流す
プロフィールを更新したよ!(からcache invalidateしてね!)というメッセージを送信する。
クライアントはmessage.idをキャッシュしておいて、まだ更新してないメッセージなら更新する。
cons: タイムラインに出ちゃう(隠せるがいちいちfilterするのめんどくない) (個人的には出ても良いのではという気もするがサイレントにしたい人もいるかも?)

案3 associationにして次回メッセージ送信時に自己associationする
プロフィールを更新したよというassociationタイプを作って、自分の次のメッセージ送信時に自分でつける。
タイムラインには出ないし取り回しは良いが、メッセージを出すまで気づかれない。

@totegamma totegamma changed the title MessageやCharacter(Profile)、StreamなどのDict系を恒久ストレージにキャッシュする MessageやCharacter(Profile)、Streamなどリソースを恒久ストレージにキャッシュする May 29, 2023
@totegamma totegamma modified the milestones: Version0, Version2 May 29, 2023
@totegamma
Copy link
Owner Author

swでキャッシュする

message: networkfirst
association: revalidate
character: revalidate
entity: revalidate
stream: revalidate

また、workboxのプラグインを書いてfetchAPIからリクエストがキャッシュだったのかどうかをis-from-cacheヘッダで返すようにしたい

@totegamma totegamma changed the title MessageやCharacter(Profile)、Streamなどリソースを恒久ストレージにキャッシュする swでAPIアクセスをキャッシュする Jul 4, 2023
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

1 participant