zxCoder
V2EX  ›  问与答

网站前端更新了,怎么提示让用户 ctlr+F5 刷新一下呢,不然总是执行了缓存的老代码

  •  
  •   zxCoder · Aug 20, 2021 · 1831 views
    This topic created in 1913 days ago, the information mentioned may be changed or developed.
    happyeveryday
    happyeveryday
    Aug 20, 2021
    1
    一般资源通过打 hash 能避免缓存,不过遇到过 index.html 被缓存了就比较麻烦
    eason1874
    eason1874
    Aug 20, 2021
    2
    网页禁止缓存,静态文件资源路径加上版本号或者 hash,就 OK 了
    lynan
    lynan
    Aug 20, 2021
    3
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    shakaraka
    shakaraka
    Aug 20, 2021❤️1
    4
    一般不缓存 index.html,依赖 css 、js 加 hash
    NewYear
    NewYear
    Aug 20, 2021
    5
    我们内部系统,魔改了 JS 文件,结果看到很多同事的界面,接近半年了还是用的缓存 JS 文件,吐血。
    circleee
    circleee
    Aug 20, 2021
    6
    @NewYear 这。。。
    jarl
    jarl
    Aug 20, 2021
    7
    js?version=时间戳
    css?version=时间戳
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1867 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 15:21 · PVG 23:21 · LAX 07:21 · JFK 10:21
    ♥ Do have faith in what you're doing.