nodecommons-express
Advanced tools
Comparing version 1.4.1 to 1.4.2
@@ -6,2 +6,4 @@ import * as express from 'express'; | ||
static noCache(res: express.Response): void; | ||
static cache(res: express.Response, seconds: number): void; | ||
static useCacheIfUnchanged(res: express.Response): void; | ||
private static isValidIp; | ||
@@ -8,0 +10,0 @@ static getIpAddress(req: express.Request, real?: boolean): string | undefined; |
@@ -12,2 +12,10 @@ "use strict"; | ||
} | ||
static cache(res, seconds) { | ||
res.setHeader('Cache-Control', `public, max-age=${seconds}`); | ||
} | ||
static useCacheIfUnchanged(res) { | ||
// see "Requiring revalidation": https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control | ||
// Makes browsers check for a new version, but not download if it isn't changed | ||
res.setHeader('Cache-Control', 'no-cache, max-age=0'); | ||
} | ||
static isValidIp(value) { | ||
@@ -14,0 +22,0 @@ if (value === undefined || value === null) |
@@ -10,5 +10,2 @@ /// <reference types="node" /> | ||
private readonly port; | ||
static noCache(res: express.Response): void; | ||
static cache(res: express.Response, seconds: number): void; | ||
static useCacheIfUnchanged(res: express.Response): void; | ||
static nginxProxyPath(p?: string): string; | ||
@@ -15,0 +12,0 @@ static cleanupMultiPartFiles(request: express.Request): void; |
@@ -20,2 +20,3 @@ "use strict"; | ||
const nodecommons_file_1 = require("nodecommons-file"); | ||
const commons_express_1 = require("../helpers/commons-express"); | ||
const commons_angular_exts_1 = require("../consts/commons-angular-exts"); | ||
@@ -36,15 +37,2 @@ function isFile(test) { | ||
} | ||
static noCache(res) { | ||
res.setHeader('Cache-Control', 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0'); | ||
res.setHeader('Expires', '-1'); | ||
res.setHeader('Pragma', 'no-cache'); | ||
} | ||
static cache(res, seconds) { | ||
res.setHeader('Cache-Control', `public, max-age=${seconds}`); | ||
} | ||
static useCacheIfUnchanged(res) { | ||
// see "Requiring revalidation": https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control | ||
// Makes browsers check for a new version, but not download if it isn't changed | ||
res.setHeader('Cache-Control', 'no-cache, max-age=0'); | ||
} | ||
static nginxProxyPath(p) { | ||
@@ -127,9 +115,9 @@ if (p === undefined) | ||
if (commons_angular_exts_1.COMMONS_ANGULAR_EXTS_NOCACHE.includes(ext[1])) { | ||
CommonsExpressServer.noCache(res); | ||
commons_express_1.CommonsExpress.noCache(res); | ||
} | ||
if (commons_angular_exts_1.COMMONS_ANGULAR_EXTS_CACHE.includes(ext[1])) { | ||
CommonsExpressServer.cache(res, cacheMaxAgeSeconds); | ||
commons_express_1.CommonsExpress.cache(res, cacheMaxAgeSeconds); | ||
} | ||
if (commons_angular_exts_1.COMMONS_ANGULAR_EXTS_USE_CACHE_IF_UNCHANGED.includes(ext[1])) { | ||
CommonsExpressServer.useCacheIfUnchanged(res); | ||
commons_express_1.CommonsExpress.useCacheIfUnchanged(res); | ||
} | ||
@@ -147,3 +135,3 @@ } | ||
this.ex.get(`${url}*`, (_, res) => { | ||
CommonsExpressServer.useCacheIfUnchanged(res); | ||
commons_express_1.CommonsExpress.noCache(res); | ||
res.sendFile(path.join(absolute, '/index.html')); | ||
@@ -150,0 +138,0 @@ }); |
{ | ||
"name": "nodecommons-express", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "", | ||
@@ -26,3 +26,3 @@ "scripts": { | ||
"devDependencies": { | ||
"@types/node": "^13.9.5" | ||
"@types/node": "^13.9.8" | ||
}, | ||
@@ -29,0 +29,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58566
765