#!/bin/bash # 验证首页缓存是否生效(修了 _send 重复头之后) set -u BASE=https://relay.xxmxxs.top UA='LanRemote/1.8.1' echo "════════ 1. 本机直连的缓存头(确认代码生效)════════" for p in "/" "/download/ykxmz-setup-1.8.1.exe" "/shot/pc-main.png"; do cc=$(curl -sI --max-time 15 "http://127.0.0.1:8080$p" 2>/dev/null \ | grep -i '^cache-control' | tr -d '\r') printf " %-38s %s\n" "$p" "${cc:-(无)}" done echo echo "════════ 2. 走公网看 cf-cache-status ════════" for p in "/" "/shot/pc-main.png" "/favicon.ico" "/download/ykxmz-setup-1.8.1.exe"; do echo " ── $p ──" for i in 1 2 3; do hdr=$(curl -sI --max-time 30 -H "User-Agent: $UA" "$BASE$p" 2>/dev/null | tr -d '\r') st=$(echo "$hdr" | grep -i '^cf-cache-status' | awk '{print $2}') cc=$(echo "$hdr" | grep -i '^cache-control' | cut -d' ' -f2-) age=$(echo "$hdr" | grep -i '^age:' | awk '{print $2}') printf " 第 %d 次: status=%-8s age=%-7s cc=%s\n" \ "$i" "${st:-无}" "${age:-无}" "${cc:-无}" sleep 1 done done echo echo "════════ 3. 重复头检查(不该有两个 Cache-Control)════════" n=$(curl -sI --max-time 15 "http://127.0.0.1:8080/" 2>/dev/null | grep -ci '^cache-control') echo " 本机首页的 Cache-Control 头数量: $n (应为 1)"