2

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

2
  • You can append a random string (or the time stamp when the file is updated) as a query string at the end of the resource, e.g. functions.js?v=1234567. This will effectively force the browser to retrieve the resource again regardless of its cache. Commented Nov 16, 2016 at 9:56
  • You could test and debug your application in Browsers "private mode". Commented Nov 16, 2016 at 10:09

3 Answers 3

3

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>
Sign up to request clarification or add additional context in comments.

Comments

3

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

Comments

1

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?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.