@apolitical/server 2.7.0-rc.4 → 2.8.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.8.0] - 2022-11-14
9
+ ### Added
10
+ - Cache control for static files
11
+
8
12
  ## [2.7.0] - 2022-08-22
9
13
  ### Added
10
14
  - Strict routing parameter to allow treating "/foo" and "/foo/" as different
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apolitical/server",
3
- "version": "2.7.0-rc.4",
3
+ "version": "2.8.0-beta.1",
4
4
  "description": "Node.js module to encapsulate Apolitical's express server setup",
5
5
  "author": "Apolitical Group Limited <engineering@apolitical.co>",
6
6
  "license": "MIT",
@@ -2,11 +2,11 @@
2
2
 
3
3
  module.exports = ({
4
4
  bodyParser: { json, urlencoded },
5
+ express,
5
6
  compression,
6
7
  cors,
7
8
  cookieParser,
8
9
  prerender,
9
- express,
10
10
  config,
11
11
  logger,
12
12
  }) => {
@@ -29,7 +29,19 @@ module.exports = ({
29
29
  }
30
30
  if (staticFiles) {
31
31
  const { baseUrl, folderPath } = staticFiles;
32
- app.use(baseUrl, express.static(folderPath, { index: false }));
32
+ app.use(
33
+ baseUrl,
34
+ express.static(folderPath, {
35
+ index: false,
36
+ maxAge: '1y',
37
+ setHeaders: (res, path) => {
38
+ const mimeType = express.static.mime.lookup(path);
39
+ if (mimeType === 'text/html' || mimeType === 'text/plain') {
40
+ res.setHeader('Cache-Control', 'public, max-age=0');
41
+ }
42
+ },
43
+ }),
44
+ );
33
45
  }
34
46
  childLogger.debug('Finished');
35
47
  };