If you are tired of pressing ‘ctrl+f5’ every time you update your site’s CSS (or JS) to see the changes, then here is a good idea to fool and force browsers to download the latest version of the updated files instead of using cached one. If you don’t then your visitor’s browser may well load a cached version of the CSS or JS which can result in outdated look (and broken pages).
To prevent the above scenario, we can apply versioning to css (or js) files which are frequently updated. One simple way I like to do this by appending a dynamic query string to the link.
// Get Current Datetime
$version=date("dmYHis");
<link rel="stylesheet" href="/path/to/style.css?v="<?php echo $version ?>" type="text/css"/>
<script src="/path/to/script.js?v="<?php echo $version ?>" type="text/javascript"></script>
Busting the cache is also really useful when you are pushing out changes for review (you won’t have to ask your reviewers to refresh or press ‘ctrl+f5 ‘or clear their cache to see the changes).