aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/plugins.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/plugins.ts')
-rw-r--r--server/controllers/plugins.ts19
1 files changed, 15 insertions, 4 deletions
diff --git a/server/controllers/plugins.ts b/server/controllers/plugins.ts
index f255d13e8..f5285ba3a 100644
--- a/server/controllers/plugins.ts
+++ b/server/controllers/plugins.ts
@@ -5,6 +5,12 @@ import { RegisteredPlugin } from '../lib/plugins/plugin-manager'
5import { servePluginStaticDirectoryValidator } from '../middlewares/validators/plugins' 5import { servePluginStaticDirectoryValidator } from '../middlewares/validators/plugins'
6import { serveThemeCSSValidator } from '../middlewares/validators/themes' 6import { serveThemeCSSValidator } from '../middlewares/validators/themes'
7import { PluginType } from '../../shared/models/plugins/plugin.type' 7import { PluginType } from '../../shared/models/plugins/plugin.type'
8import { isTestInstance } from '../helpers/core-utils'
9
10const sendFileOptions = {
11 maxAge: '30 days',
12 immutable: !isTestInstance()
13}
8 14
9const pluginsRouter = express.Router() 15const pluginsRouter = express.Router()
10 16
@@ -46,7 +52,12 @@ export {
46// --------------------------------------------------------------------------- 52// ---------------------------------------------------------------------------
47 53
48function servePluginGlobalCSS (req: express.Request, res: express.Response) { 54function servePluginGlobalCSS (req: express.Request, res: express.Response) {
49 return res.sendFile(PLUGIN_GLOBAL_CSS_PATH) 55 // Only cache requests that have a ?hash=... query param
56 const globalCSSOptions = req.query.hash
57 ? sendFileOptions
58 : {}
59
60 return res.sendFile(PLUGIN_GLOBAL_CSS_PATH, globalCSSOptions)
50} 61}
51 62
52function servePluginStaticDirectory (req: express.Request, res: express.Response) { 63function servePluginStaticDirectory (req: express.Request, res: express.Response) {
@@ -61,7 +72,7 @@ function servePluginStaticDirectory (req: express.Request, res: express.Response
61 } 72 }
62 73
63 const filepath = file.join('/') 74 const filepath = file.join('/')
64 return res.sendFile(join(plugin.path, staticPath, filepath)) 75 return res.sendFile(join(plugin.path, staticPath, filepath), sendFileOptions)
65} 76}
66 77
67function servePluginClientScripts (req: express.Request, res: express.Response) { 78function servePluginClientScripts (req: express.Request, res: express.Response) {
@@ -73,7 +84,7 @@ function servePluginClientScripts (req: express.Request, res: express.Response)
73 return res.sendStatus(404) 84 return res.sendStatus(404)
74 } 85 }
75 86
76 return res.sendFile(join(plugin.path, staticEndpoint)) 87 return res.sendFile(join(plugin.path, staticEndpoint), sendFileOptions)
77} 88}
78 89
79function serveThemeCSSDirectory (req: express.Request, res: express.Response) { 90function serveThemeCSSDirectory (req: express.Request, res: express.Response) {
@@ -84,5 +95,5 @@ function serveThemeCSSDirectory (req: express.Request, res: express.Response) {
84 return res.sendStatus(404) 95 return res.sendStatus(404)
85 } 96 }
86 97
87 return res.sendFile(join(plugin.path, staticEndpoint)) 98 return res.sendFile(join(plugin.path, staticEndpoint), sendFileOptions)
88} 99}