Disable browser caching for css and js file during development

一笑奈何 提交于 2020-01-05 05:24:25

问题


How can we disable browser cache during application development process so that whenever we make any changes to the css or js files in localhost(or any development environment) we don't have to do a hard refresh on the browser to see the changes


回答1:


Try this for all css and js. This example you should add time in all css and js

  <link rel="stylesheet" type="text/css" href="style.css?<?php echo date('l jS \of F Y h:i:s A'); ?>" />

or
<link href="/css/styles.css?ver=<?php echo time();?>" rel="stylesheet">

or
 <script src="/js/site.js?ver=<?php echo time();?>"></script>



回答2:


Most browsers (Chrome and Firefox are shown in the screenshots below) have an option in the Network tab of the Developer's Tools to disable caching while the Developer Tools are open.




回答3:


caching is good for fast development, but in case of chrome you can right click on the refresh button and find the options:

Hope this helps?



来源:https://stackoverflow.com/questions/40628864/disable-browser-caching-for-css-and-js-file-during-development

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!