Fix caching on server
Build and publish docker image snapshot / build-and-publish (push) Successful in 1m14s Details

This commit is contained in:
Stefan Forstenlechner 2024-08-20 23:35:06 +02:00
parent 111dee8e7e
commit 5d0a9fdefe
3 changed files with 31 additions and 12 deletions

View File

@ -12,6 +12,7 @@
"express": "4.19.2", "express": "4.19.2",
"express-winston": "4.2.0", "express-winston": "4.2.0",
"natsort": "2.0.3", "natsort": "2.0.3",
"serve-static": "^1.15.0",
"sharp": "0.33.4", "sharp": "0.33.4",
"winston": "3.14.1" "winston": "3.14.1"
}, },
@ -19,6 +20,7 @@
"@types/express": "4.17.21", "@types/express": "4.17.21",
"@types/jest": "29.5.12", "@types/jest": "29.5.12",
"@types/node": "22.2.0", "@types/node": "22.2.0",
"@types/serve-static": "^1.15.7",
"@typescript-eslint/eslint-plugin": "8.0.1", "@typescript-eslint/eslint-plugin": "8.0.1",
"@typescript-eslint/parser": "8.0.1", "@typescript-eslint/parser": "8.0.1",
"eslint": "^8.57.0", "eslint": "^8.57.0",
@ -1754,6 +1756,12 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"node_modules/@types/http-errors": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz",
"integrity": "sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==",
"dev": true
},
"node_modules/@types/istanbul-lib-coverage": { "node_modules/@types/istanbul-lib-coverage": {
"version": "2.0.6", "version": "2.0.6",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz",
@ -1832,13 +1840,14 @@
} }
}, },
"node_modules/@types/serve-static": { "node_modules/@types/serve-static": {
"version": "1.13.10", "version": "1.15.7",
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.10.tgz", "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.7.tgz",
"integrity": "sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ==", "integrity": "sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@types/mime": "^1", "@types/http-errors": "*",
"@types/node": "*" "@types/node": "*",
"@types/send": "*"
} }
}, },
"node_modules/@types/stack-utils": { "node_modules/@types/stack-utils": {
@ -9117,6 +9126,12 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"@types/http-errors": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz",
"integrity": "sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==",
"dev": true
},
"@types/istanbul-lib-coverage": { "@types/istanbul-lib-coverage": {
"version": "2.0.6", "version": "2.0.6",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz",
@ -9195,13 +9210,14 @@
} }
}, },
"@types/serve-static": { "@types/serve-static": {
"version": "1.13.10", "version": "1.15.7",
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.10.tgz", "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.7.tgz",
"integrity": "sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ==", "integrity": "sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/mime": "^1", "@types/http-errors": "*",
"@types/node": "*" "@types/node": "*",
"@types/send": "*"
} }
}, },
"@types/stack-utils": { "@types/stack-utils": {

View File

@ -21,6 +21,7 @@
"@types/express": "4.17.21", "@types/express": "4.17.21",
"@types/jest": "29.5.12", "@types/jest": "29.5.12",
"@types/node": "22.2.0", "@types/node": "22.2.0",
"@types/serve-static": "^1.15.7",
"@typescript-eslint/eslint-plugin": "8.0.1", "@typescript-eslint/eslint-plugin": "8.0.1",
"@typescript-eslint/parser": "8.0.1", "@typescript-eslint/parser": "8.0.1",
"eslint": "^8.57.0", "eslint": "^8.57.0",
@ -41,6 +42,7 @@
"express": "4.19.2", "express": "4.19.2",
"express-winston": "4.2.0", "express-winston": "4.2.0",
"natsort": "2.0.3", "natsort": "2.0.3",
"serve-static": "^1.15.0",
"sharp": "0.33.4", "sharp": "0.33.4",
"winston": "3.14.1" "winston": "3.14.1"
} }

View File

@ -1,12 +1,13 @@
import express from "express"; import express from "express";
import * as path from "path"; import * as path from "path";
import { ServeStaticOptions } from "serve-static";
import { publicPath } from "../paths"; import { publicPath } from "../paths";
export const routerHtml = express.Router(); export const routerHtml = express.Router();
const withCaching = { const withCaching: ServeStaticOptions = {
maxAge: 2592000000, maxAge: 2592000000,
setHeaders(res, _) { setHeaders: (res, _) => {
res.setHeader( res.setHeader(
"Expires", "Expires",
new Date(Date.now() + 2592000000 * 30).toUTCString(), new Date(Date.now() + 2592000000 * 30).toUTCString(),