Force refresh css js browser

Sometimes when you are making lots of changes to css and js it is annoying that the browser keeps your cache and is quite persistent about it.

During development mode i use these for CSS and JS.

The idea is that by adding a    ?v=<time> to the end of the filename  filename.css?v=<time>

we make the browser thinks it is a different file therefore retrieves it instead of using the one in the cache.

This is able to happen because of the GET http method.

HTML

 

PHP

JS

 

Hope this helps. Let me know if there are other ways as well.

Submit a Comment