Skip to content

Use lru-cache@11. #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# bedrock-manifest-proxy ChangeLog

## 4.1.0 - 2025-05-dd

### Changed
- Use `lru-cache@11`.

## 4.0.0 - 2023-10-13

### Changed
Expand Down
12 changes: 5 additions & 7 deletions lib/http.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
/*!
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
* Copyright (c) 2019-2025 Digital Bazaar, Inc. All rights reserved.
*/
import * as bedrock from '@bedrock/core';
import {asyncHandler} from '@bedrock/express';
import CachePolicy from 'http-cache-semantics';
import contentType from 'content-type';
import {createRequire} from 'node:module';
import {httpClient} from '@digitalbazaar/http-client';
import {httpsAgent} from '@bedrock/https-agent';
const require = createRequire(import.meta.url);
const LRU = require('lru-cache');
import {LRUCache as LRU} from 'lru-cache';

const {config, util: {BedrockError}} = bedrock;

Expand All @@ -20,8 +18,8 @@ let MANIFEST_CACHE;
bedrock.events.on('bedrock.init', () => {
// init web app manifest cache
MANIFEST_CACHE = new LRU({
max: config['manifest-proxy'].manifestCache.size,
length({response}) {
maxSize: config['manifest-proxy'].manifestCache.size,
sizeCalculation({response}) {
const headerLength = JSON.stringify(response.headers).length;
return headerLength + (response.data ? response.data.length : 0);
}
Expand Down Expand Up @@ -115,7 +113,7 @@ async function getResponse({host}) {

// update cache
freshUntil = Date.now() + config['manifest-proxy'].manifestCache.ttl;
MANIFEST_CACHE.set(manifestUrl, {policy, response, freshUntil}, ttl);
MANIFEST_CACHE.set(manifestUrl, {policy, response, freshUntil}, {ttl});

// update response header using latest policy
response.headers = policy.responseHeaders();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@digitalbazaar/http-client": "^4.0.0",
"content-type": "^1.0.4",
"http-cache-semantics": "^4.1.0",
"lru-cache": "^6.0.0"
"lru-cache": "^11.1.0"
},
"peerDependencies": {
"@bedrock/core": "^6.0.0",
Expand Down