Sometimes you update your stylesheet and and you don’t see any effects on the browser as if you had never mad any change.
To reduce number of sent requests to the server and also to make the website runs faster as the lower the browser sends requests the faster it will load the website.
A very simple yet powerful solution is to
trick the browser by telling him this is a new link so please download it.
Add at the end of your link a query string with any random value each time you want the browser to redownload the stylesheet file.
<link rel="stylesheet" href="my-style.css?v=1.0"
This will tell the browser to send a request to the server to get the file
my-style.css?v=1.0 while this is just the same stylesheet but the browser doesn’t know this yet.
If you’re using a server side language like PHP, you can generate a random string each time so the browser will always download the latest version from the server instead of the cache.
<link rel="stylesheet" href="my-style.css?v=<?php echo mt_rand(); ?>"
mt_rand function will generate a new random number for each time a request is sent to serve the page that loads that stylesheet.
The method listed above will reduce this issue from being happened once again.