coder_123
coder_123

Reputation: 21

Disable browser caching for css and js file during development

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

Upvotes: 2

Views: 6936

Answers (3)

Kubaizi
Kubaizi

Reputation: 57

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

enter image description here

Hope this helps?

Upvotes: 1

Quentin
Quentin

Reputation: 943100

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.

Firefox

Chrome

Upvotes: 3

Hansraj Systematix
Hansraj Systematix

Reputation: 104

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>

Upvotes: 3

Related Questions