-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
enhance: アバターをサーバーで圧縮して取得する #8337
Conversation
Co-authored-by: tamaina <tamaina@hotmail.co.jp>
クライアントサイド画像圧縮の準備
言うまでもなくp1.a9z.devで動作中 |
return `${config.url}/identicon/${user.id}`; | ||
return this.getIdenticonUrl(user); | ||
} | ||
} | ||
|
||
public getIdenticonUrl(user: User): string { | ||
return `${config.url}/identicon/${user.id}`; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why moving the same code into a separate function is necessary? Since its only one line, at most I think a comment would make sense here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used at
return ctx.redirect(Users.getIdenticonUrl(user)); |
//#endregion | ||
|
||
ctx.set('Content-Type', 'image/webp'); | ||
ctx.set('Cache-Control', 'max-age=31536000, immutable'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since avatars can change multiple times in the span of a year I think this caching is a bit too agressive. I think something between a week and a month might make more sense? Or remove immutable
because that is not the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここに至るまでに、クエリ文字列にurlを持たない場合はリダイレクトされるはずなのですが、どうでしょうか。
アバターって本来thumbnailが挿入されるべきなんだけど、p1.a9z.dev(TLに出現するのがほとんどリモートユーザー)でwebpublicばっかりになっているのは #7767 のバグのせいだということを理解した… |
A part of #8319
#8216 のつづき
What
/avatar.webp
にクエリ付きでアクセスすると、256x256にクロップ(cover)したアバターwebpを取得する or identiconへリダイレクト/avatar
は削除Why
通信量削減