冷首访白屏的第二个真因:/contact 用 useSearchParams() 读 ?success,客户端组件里 这会让整页在预渲染时退化成 Suspense fallback(首访只看到「加载中…」,限速下 ~6s 才出内容)。 该参数只用于一次性成功提示 ⇒ 改为挂载后从 window.location 读并 replaceState 清理。 - /contact 冷首访 h1 可见:6.0s → 1.5s;HTML 73KB 含正文(此前只有外壳)。 - 新增 scripts/ops/warm-routes.mjs:按 sitemap 预热并断言全 200、第二遍 <1500ms 或 HIT; 本轮线上第二遍:非 200 = 0、>1500ms = 0。 - 全站冷首访复测:/ 827ms、/about 1652ms、/contact 1511ms、/products 917ms、 /services/software 922ms、/insights 1532ms。 - runbook:加发布前磁盘检查(≥2G)与「构建失败必须中止」;加 §4.0 预热步骤。 - 事故记录:第三次重建时服务器磁盘 99%,COPY 报 ENOSPC 而 up -d 仍执行(旧镜像被当已发布); 清理旧备份 1.8G + docker image prune 1.075G 后回到 81%,重建 015b6d75 成功。
26 lines
1.4 KiB
JavaScript
26 lines
1.4 KiB
JavaScript
import { chromium } from 'playwright';
|
|
const routes = ['/', '/about', '/contact', '/products', '/services/software', '/insights'];
|
|
const b = await chromium.launch();
|
|
for (const r of routes) {
|
|
const ctx = await b.newContext({ viewport:{width:1280,height:900} });
|
|
const p = await ctx.newPage();
|
|
const cdp = await ctx.newCDPSession(p);
|
|
await cdp.send('Network.enable');
|
|
await cdp.send('Network.setCacheDisabled', { cacheDisabled: true });
|
|
await cdp.send('Network.emulateNetworkConditions', { offline:false, latency:150, downloadThroughput: 900*1024/8, uploadThroughput: 400*1024/8 });
|
|
p.goto('https://www.novalon.cn'+r, { waitUntil:'commit', timeout:90000 }).catch(()=>{});
|
|
let firstVisible = null, s = null;
|
|
for (let i=0;i<70;i++) {
|
|
s = await p.evaluate(() => {
|
|
const h1 = document.querySelector('h1'); const cs = h1 ? getComputedStyle(h1) : null;
|
|
return h1 ? { t: Math.round(performance.now()), op: Number(cs.opacity), visible: document.visibilityState } : null;
|
|
}).catch(()=>null);
|
|
if (s && s.op === 1) { firstVisible = s.t; break; }
|
|
await p.waitForTimeout(120);
|
|
}
|
|
console.log(r.padEnd(20), firstVisible !== null ? `h1 可见@${firstVisible}ms` : 'NOT VISIBLE in window');
|
|
if (r === '/about') await p.screenshot({ path:'docs/acceptance/2026-10-20-prod-about/about-cold-after-fix.png', fullPage:false });
|
|
await ctx.close();
|
|
}
|
|
await b.close();
|