改了 DNS 記錄,為什麼還有人看到舊網站?看懂 TTL 與快取 / Why Your DNS Change Is Not Live Yet: TTL and Caching
現象:改是改了,答案還是舊的 / The record changed, yet old answers persist 假設你把網站搬到新主機,在 DNS 管理介面把 A 記錄改成新 IP,自己測試也正常;幾分鐘後同事回報,看到的還是舊網站。先別急著把記錄改第二次:可能不是改失敗,而是查詢本身沒有走到你修改的那台伺服器。 Suppose you move a site to a new host and update its DNS A record in the management console; your own test works, yet minutes later a colleague reports the old site is still being served. Do not rush to edit the record a second time: the change may not have failed — the query itself may never have reached the server you edited. 在終端機輸入網址,多數情況不是直接去問「管這個網域的伺服器」,而是交給遞迴解析器代問,例如寬頻業者的解析器或公共 DNS。依 RFC 1034,DNS 定義了快取所取得資料的程序;解析器替很多使用者共用同一份答案,你問到的可能是幾分鐘前別人問過的副本,而不是最新狀態。[1] When you type a hostname, you are usually not addressing the servers that manage the zone directly. A recursive resolver asks on your behalf — the resolver of your broadband provider or a public DNS, for example. RFC 1034 defines procedures for caching retrieved data, so a resolver serves the same copy of an answer to many users: what you receive may be a copy fetche...