冷首访白屏的第二个真因:/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 成功。
24 lines
1.4 KiB
JavaScript
24 lines
1.4 KiB
JavaScript
import { chromium } from 'playwright';
|
|
const b = await chromium.launch();
|
|
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:120, downloadThroughput: 120*1024*8, uploadThroughput: 60*1024*8 });
|
|
p.goto('https://www.novalon.cn/about', { waitUntil:'commit', timeout:90000 }).catch(()=>{});
|
|
for (const wait of [900, 1500, 3000]) {
|
|
await p.waitForTimeout(wait === 900 ? 900 : wait - 900);
|
|
const snap = await p.evaluate(() => {
|
|
const h1 = document.querySelector('h1');
|
|
const chain = [];
|
|
let el = h1;
|
|
while (el) { chain.push(`${el.tagName}${el.className?'.'+String(el.className).split(' ')[0]:''} op=${getComputedStyle(el).opacity}`); el = el.parentElement; }
|
|
const zeros = [...document.querySelectorAll('body *')].filter(e => parseFloat(getComputedStyle(e).opacity) === 0)
|
|
.slice(0,8).map(e => ({ tag:e.tagName, cls:String(e.className).slice(0,46), text:(e.innerText||'').slice(0,16) }));
|
|
return { t: Math.round(performance.now()), h1op: h1 ? getComputedStyle(h1).opacity : null, chain: chain.slice(0,9), zeros };
|
|
}).catch(()=>null);
|
|
console.log('@'+wait+'ms', JSON.stringify(snap));
|
|
}
|
|
await b.close();
|