douduan7295 2017-06-25 17:26
浏览 32
已采纳

我的网络服务器不会注册css文件更改[重复]

This question already has an answer here:

At first, when I saw in the Chrome Developer console that my CSS file was not updating, I thought it was a problem with my text editor. So I switched from VSCode to Sublime 3 and encountered the same error. It had updated slightly, but not much. So after a while I swithced again to Atom, and still encountered the same problem. I even switched my Webserver from MAMP for Windows to XAMPP. Still no dice. When I say updating, I mean the file would save, but the changes wouldn't appear in my browser.

</div>
  • 写回答

1条回答 默认 最新

  • dongwei2983 2017-06-25 17:32
    关注

    This is the issue with browser caching, and clearing it every time you update your CSS isn't a viable solution.

    You can either go the short route and open your website in incognito mode. This will clear cache each time you revisit the page.

    I recommend you disable caching for your website while working on it. I assue you're running Apache on your server, and then it's simply a matter of including this tag in your .htaccess file.

    <IfModule mod_headers.c>
        Header set Cache-Control "no-cache, no-store, must-revalidate"
        Header set Pragma "no-cache"
        Header set Expires 0
    </IfModule>
    

    or this snippet in your HTML <head>

    <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" />
    

    Follow these instruction for a more in-depth implementation How to control web page caching, across all browsers?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败