Files
happy-export/backend/package.json
T
DrsakuraandClaude Opus 5 dc607e4ea3 perf(static): 带 hash 的前端资源缓存一年,index.html 不缓存
线上实测 /assets/index-u1PUen4p.js 返回的是 express.static 的默认
Cache-Control: public, max-age=0 —— 每开一次页面就要为每个 JS/CSS 跑一趟
回源校验。而这些文件名里本来就带内容 hash,内容一变文件名就变。

分两档:
  assets/*    max-age=31536000, immutable(连 304 都不用问)
  index.html  no-cache

index.html 必须不缓存:它文件名固定、里面引用的才是带 hash 的资源名。
缓存住的话发了新版用户还拿着旧 index.html、指向旧资源,等于白更新。

SPA fallback 那条单独加了一遍 no-cache —— 它走 sendFile,不经过
express.static 的 setHeaders,/orders 这类深链拿到的同样是 index.html。

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-10-22 16:17:44 +08:00

28 lines
596 B
JSON

{
"name": "trade-management-backend",
"version": "1.1.1",
"description": "外贸供应链管理系统 - 后端",
"main": "server.js",
"scripts": {
"start": "node server.js",
"dev": "nodemon server.js"
},
"keywords": [
"trade",
"crm",
"supply-chain"
],
"author": "",
"license": "ISC",
"dependencies": {
"better-sqlite3-multiple-ciphers": "^13.0.3",
"cors": "^2.8.5",
"express": "^4.18.2",
"multer": "^1.4.5-lts.1",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
},
"devDependencies": {
"nodemon": "^3.0.1"
}
}