1/** 2 * Shared cache configuration for the Archive's storage layer. 3 * 4 * archiveService.js reads the entity payload cache through these constants 5 * and the key hash below, so they live here rather than inline: bumping 6 * CACHE_VERSION in one place invalidates every cache by construction, 7 * instead of relying on a "bump it everywhere" comment a future edit can 8 * forget. (Formerly shared with loaders/httpCachedLoader.js, an unwired 9 * entity-loading path removed in #503.) 10 */ 11 12// Increment to invalidate all caches (e.g. after a breaking payload change). 13// v11: the 3.8.34 data release genuinely changed the archive payloads -- seven 14// duplicate records dropped (#867), RECORD-00918 added by the RECORD-00429 15// split (#863), and the duplicate PressThink entity merged into O0033 (#859). 16// A returning visitor holding a v10 payload would otherwise be served records 17// that no longer exist, and a stale entity graph, for up to CACHE_TTL_MS after 18// deploy. 19export const CACHE_VERSION = 'v11'; 20 21// Entity data is small (~1MB), so a short TTL keeps it current cheaply. 22export const CACHE_TTL_MS = 1000 * 60 * 30; // 30 minutes 23 24// localStorage quota is ~5MB; larger payloads go to sessionStorage instead. 25export const MAX_LOCALSTORAGE_SIZE = 5 * 1024 * 1024; 26 27/** 28 * djb2 hash of the data URL, namespaced under archive_json_. archiveService's 29 * cache addresses entries with this exact key. 30 * @param {string} url 31 * @returns {string} 32 */ 33export const cacheKeyFor = (url) => { 34 let hash = 5381; 35 for (let i = 0; i < url.length; i += 1) { 36 hash = ((hash << 5) + hash) + url.charCodeAt(i); 37 } 38 return `archive_json_${Math.abs(hash >>> 0)}`; 39};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.