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 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?