vanilla-jet 1.6.0 → 1.6.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
@@ -4,6 +4,21 @@ All notable project changes are documented in this file.
4
4
 
5
5
  The format follows a structure inspired by Keep a Changelog and semantic versioning.
6
6
 
7
+ ## [1.6.1] - 2026-06-29
8
+
9
+ ### Security
10
+
11
+ - **Removed unused dependencies that carried known vulnerabilities:** `jsrsasign` (multiple high/critical
12
+ crypto advisories), `jwt-simple`, `blueimp-md5`, `js-beautify`, and `nodemon`. None were used by the
13
+ framework; this drops a large vulnerability + install-size footprint for consumers.
14
+
15
+ ### Added
16
+
17
+ - **`settings.profile.static_cache_max_age`** (seconds, default `0`): sets `Cache-Control: public, max-age=N`
18
+ for NON-versioned static assets (images, fonts, animation JSON…), so they are reused across references
19
+ and reloads instead of revalidating every time. Versioned (`?v=`) assets stay `immutable`; `0` keeps the
20
+ previous `no-cache` behavior. Pairs with the service worker for clients without it (e.g. WebViews).
21
+
7
22
  ## [1.6.0] - 2026-06-29
8
23
 
9
24
  ### Added
@@ -46,6 +46,10 @@ class Router {
46
46
  this.compressionFiles = [ 'vanilla.min.js', 'app.min.css' ];
47
47
  this.enablePrecompressedNegotiation = Boolean(server?.options?.enable_precompressed_negotiation);
48
48
  this.enableServiceWorker = Boolean(server?.options?.enable_service_worker);
49
+ // Cache-Control max-age (seconds) for NON-versioned static assets (images, fonts,
50
+ // animation JSON…). Lets the browser reuse them across references/reloads instead of
51
+ // revalidating each time. Versioned (?v=) assets stay immutable; 0 keeps no-cache.
52
+ this.staticCacheMaxAge = Number(server?.options?.static_cache_max_age) || 0;
49
53
  }
50
54
 
51
55
  routeToRegExp(route) {
@@ -284,6 +288,7 @@ class Router {
284
288
  }
285
289
 
286
290
  buildStaticHeaders(extHeader, candidates, contentEncoding, metadata, isImmutable) {
291
+ let obj = this;
287
292
  let staticHeaders = Object.assign({}, extHeader);
288
293
  if (contentEncoding) {
289
294
  staticHeaders['Content-Encoding'] = contentEncoding;
@@ -300,8 +305,13 @@ class Router {
300
305
  // This is the big win for clients without the service worker (e.g. native WebViews),
301
306
  // which otherwise revalidate every asset on every load.
302
307
  staticHeaders['Cache-Control'] = 'public, max-age=31536000, immutable';
308
+ } else if (obj.staticCacheMaxAge > 0) {
309
+ // Non-versioned assets (images, fonts, animation JSON…): cache for a while so they
310
+ // aren't re-fetched on every reference/reload. ETag/Last-Modified still allow a cheap
311
+ // 304 after expiry. Pick this when assets change rarely (e.g. a few days/weeks).
312
+ staticHeaders['Cache-Control'] = `public, max-age=${obj.staticCacheMaxAge}`;
303
313
  } else {
304
- // Non-versioned assets: force revalidation to keep clients fresh without a hard reload.
314
+ // Default: force revalidation to keep clients fresh without a hard reload.
305
315
  staticHeaders['Cache-Control'] = 'no-cache, must-revalidate';
306
316
  }
307
317
  return staticHeaders;
@@ -38,6 +38,7 @@ class Server {
38
38
  enable_precompressed_negotiation: false,
39
39
  enable_service_worker: false,
40
40
  defer_scripts: false,
41
+ static_cache_max_age: 0,
41
42
  request_timeout_ms: 30000,
42
43
  headers_timeout_ms: 35000,
43
44
  keep_alive_timeout_ms: 5000
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vanilla-jet",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "VannilaJet framework",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -30,14 +30,9 @@
30
30
  },
31
31
  "homepage": "https://github.com/nalancer08/VanillaJet#readme",
32
32
  "dependencies": {
33
- "blueimp-md5": "2.19.0",
34
33
  "chalk": "4.1.2",
35
34
  "html-minifier-terser": "7.2.0",
36
- "js-beautify": "1.15.4",
37
- "jsrsasign": "11.1.0",
38
- "jwt-simple": "0.5.6",
39
35
  "minimist": "1.2.8",
40
- "nodemon": "3.1.10",
41
36
  "nunjucks": "3.2.4",
42
37
  "underscore": ">= 1.12.x",
43
38
  "del": "^6.0.0",
@@ -48,6 +48,18 @@ test('isProtectedFile: blocks framework/external/node_modules and top-level file
48
48
  assert.equal(router.isProtectedFile('/public/scripts/vanilla.min.js'), false);
49
49
  });
50
50
 
51
+ test('buildStaticHeaders: immutable for ?v=, max-age when configured, else no-cache', () => {
52
+ const meta = { size: 10, etag: 'W/"x"', lastModified: 'Mon, 01 Jan 2024 00:00:00 GMT' };
53
+ const plain = makeRouter();
54
+ assert.match(plain.buildStaticHeaders({}, [], '', meta, true)['Cache-Control'], /immutable/);
55
+ assert.match(plain.buildStaticHeaders({}, [], '', meta, false)['Cache-Control'], /no-cache/);
56
+
57
+ const cached = new Router({ options: { static_cache_max_age: 3600 } });
58
+ assert.match(cached.buildStaticHeaders({}, [], '', meta, false)['Cache-Control'], /max-age=3600/);
59
+ // Versioned still wins over max-age.
60
+ assert.match(cached.buildStaticHeaders({}, [], '', meta, true)['Cache-Control'], /immutable/);
61
+ });
62
+
51
63
  test('mimes: serves common web fonts and icons', () => {
52
64
  const router = makeRouter();
53
65
  assert.equal(router.mimes['woff2'], 'font/woff2');