V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
zxCoder
V2EX  ›  问与答

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

  •  
  •   zxCoder · 2021-08-20 11:20:02 +08:00 · 1010 次点击
    这是一个创建于 979 天前的主题,其中的信息可能已经有所发展或是发生改变。
    happyeveryday
        1
    happyeveryday  
       2021-08-20 11:22:29 +08:00
    一般资源通过打 hash 能避免缓存,不过遇到过 index.html 被缓存了就比较麻烦
    eason1874
        2
    eason1874  
       2021-08-20 11:28:52 +08:00
    网页禁止缓存,静态文件资源路径加上版本号或者 hash,就 OK 了
    lynan
        3
    lynan  
       2021-08-20 11:41:58 +08:00
    <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" />
    wunonglin
        4
    wunonglin  
       2021-08-20 11:44:21 +08:00   ❤️ 1
    一般不缓存 index.html,依赖 css 、js 加 hash
    NewYear
        5
    NewYear  
       2021-08-20 11:56:58 +08:00
    我们内部系统,魔改了 JS 文件,结果看到很多同事的界面,接近半年了还是用的缓存 JS 文件,吐血。
    circleee
        6
    circleee  
       2021-08-20 12:39:56 +08:00
    @NewYear 这。。。
    jarl
        7
    jarl  
       2021-08-20 13:50:16 +08:00
    js?version=时间戳
    css?version=时间戳
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   980 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 21:27 · PVG 05:27 · LAX 14:27 · JFK 17:27
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.