diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-11 09:44:04 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-11 15:24:17 +0200 |
commit | fd4484f19eae8b0a0c30d5d30e98880c8708516a (patch) | |
tree | 9dcb357413c84797b79e301fb843b1695e20d902 /server/controllers | |
parent | 8a2db2e8cb67f7f802ecb35be7b9154695f1a6ec (diff) | |
download | PeerTube-fd4484f19eae8b0a0c30d5d30e98880c8708516a.tar.gz PeerTube-fd4484f19eae8b0a0c30d5d30e98880c8708516a.tar.zst PeerTube-fd4484f19eae8b0a0c30d5d30e98880c8708516a.zip |
Cache AP video route for 5 seconds
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/activitypub/client.ts | 4 | ||||
-rw-r--r-- | server/controllers/feeds.ts | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index f5ac9c466..5199b3f81 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts | |||
@@ -3,7 +3,7 @@ import * as express from 'express' | |||
3 | import { VideoPrivacy } from '../../../shared/models/videos' | 3 | import { VideoPrivacy } from '../../../shared/models/videos' |
4 | import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' | 4 | import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' |
5 | import { pageToStartAndCount } from '../../helpers/core-utils' | 5 | import { pageToStartAndCount } from '../../helpers/core-utils' |
6 | import { ACTIVITY_PUB, CONFIG } from '../../initializers' | 6 | import { ACTIVITY_PUB, CONFIG, ROUTE_CACHE_LIFETIME } from '../../initializers' |
7 | import { buildVideoAnnounce } from '../../lib/activitypub/send' | 7 | import { buildVideoAnnounce } from '../../lib/activitypub/send' |
8 | import { audiencify, getAudience } from '../../lib/activitypub/send/misc' | 8 | import { audiencify, getAudience } from '../../lib/activitypub/send/misc' |
9 | import { createActivityData } from '../../lib/activitypub/send/send-create' | 9 | import { createActivityData } from '../../lib/activitypub/send/send-create' |
@@ -17,6 +17,7 @@ import { VideoModel } from '../../models/video/video' | |||
17 | import { VideoChannelModel } from '../../models/video/video-channel' | 17 | import { VideoChannelModel } from '../../models/video/video-channel' |
18 | import { VideoCommentModel } from '../../models/video/video-comment' | 18 | import { VideoCommentModel } from '../../models/video/video-comment' |
19 | import { VideoShareModel } from '../../models/video/video-share' | 19 | import { VideoShareModel } from '../../models/video/video-share' |
20 | import { cacheRoute } from '../../middlewares/cache' | ||
20 | 21 | ||
21 | const activityPubClientRouter = express.Router() | 22 | const activityPubClientRouter = express.Router() |
22 | 23 | ||
@@ -34,6 +35,7 @@ activityPubClientRouter.get('/accounts?/:name/following', | |||
34 | ) | 35 | ) |
35 | 36 | ||
36 | activityPubClientRouter.get('/videos/watch/:id', | 37 | activityPubClientRouter.get('/videos/watch/:id', |
38 | executeIfActivityPub(asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.ACTIVITY_PUB.VIDEOS))), | ||
37 | executeIfActivityPub(asyncMiddleware(videosGetValidator)), | 39 | executeIfActivityPub(asyncMiddleware(videosGetValidator)), |
38 | executeIfActivityPub(asyncMiddleware(videoController)) | 40 | executeIfActivityPub(asyncMiddleware(videoController)) |
39 | ) | 41 | ) |
diff --git a/server/controllers/feeds.ts b/server/controllers/feeds.ts index 08f179509..92cf85050 100644 --- a/server/controllers/feeds.ts +++ b/server/controllers/feeds.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { CONFIG, FEEDS } from '../initializers/constants' | 2 | import { CONFIG, FEEDS, ROUTE_CACHE_LIFETIME } from '../initializers/constants' |
3 | import { asyncMiddleware, feedsValidator, setDefaultSort, videosSortValidator } from '../middlewares' | 3 | import { asyncMiddleware, feedsValidator, setDefaultSort, videosSortValidator } from '../middlewares' |
4 | import { VideoModel } from '../models/video/video' | 4 | import { VideoModel } from '../models/video/video' |
5 | import * as Feed from 'pfeed' | 5 | import * as Feed from 'pfeed' |
@@ -12,8 +12,8 @@ const feedsRouter = express.Router() | |||
12 | feedsRouter.get('/feeds/videos.:format', | 12 | feedsRouter.get('/feeds/videos.:format', |
13 | videosSortValidator, | 13 | videosSortValidator, |
14 | setDefaultSort, | 14 | setDefaultSort, |
15 | asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.FEEDS)), | ||
15 | asyncMiddleware(feedsValidator), | 16 | asyncMiddleware(feedsValidator), |
16 | asyncMiddleware(cacheRoute), | ||
17 | asyncMiddleware(generateFeed) | 17 | asyncMiddleware(generateFeed) |
18 | ) | 18 | ) |
19 | 19 | ||