diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2018-08-11 18:04:59 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2018-08-11 18:04:59 +0900 |
| commit | a8f142096cebaa262e224f805bb58b68f28aefef (patch) | |
| tree | 457ea5d522f5c7633d0852b1f55057858526de1e /src | |
| parent | 5.21.0 (diff) | |
| download | sharkey-a8f142096cebaa262e224f805bb58b68f28aefef.tar.gz sharkey-a8f142096cebaa262e224f805bb58b68f28aefef.tar.bz2 sharkey-a8f142096cebaa262e224f805bb58b68f28aefef.zip | |
Cache failed url-preview (apply to proxy/client) (#2154)
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/app/common/views/components/url-preview.vue | 14 | ||||
| -rw-r--r-- | src/server/web/url-preview.ts | 4 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/client/app/common/views/components/url-preview.vue b/src/client/app/common/views/components/url-preview.vue index 4f1e34c6ca..34f2558c69 100644 --- a/src/client/app/common/views/components/url-preview.vue +++ b/src/client/app/common/views/components/url-preview.vue @@ -104,13 +104,15 @@ export default Vue.extend({ } fetch('/url?url=' + encodeURIComponent(this.url)).then(res => { res.json().then(info => { - this.title = info.title; - this.description = info.description; - this.thumbnail = info.thumbnail; - this.icon = info.icon; - this.sitename = info.sitename; + if (info.url != null) { + this.title = info.title; + this.description = info.description; + this.thumbnail = info.thumbnail; + this.icon = info.icon; + this.sitename = info.sitename; - this.fetching = false; + this.fetching = false; + } }); }); } diff --git a/src/server/web/url-preview.ts b/src/server/web/url-preview.ts index 99ee2eaebd..e96eb309fe 100644 --- a/src/server/web/url-preview.ts +++ b/src/server/web/url-preview.ts @@ -14,7 +14,9 @@ module.exports = async (ctx: Koa.Context) => { ctx.body = summary; } catch (e) { - ctx.status = 500; + ctx.status = 200; + ctx.set('Cache-Control', 'max-age=86400, immutable'); + ctx.body = '{}'; } }; |