External CSS with certain hosting providers

This question is unrelated to Wappler but I just want to know.

90% of the websites I create, I can attach an external CSS stylesheet like this and it works perfectly.

<link rel="stylesheet" type="text/css" href="/my-styles.css">

For some reason 10% of the time the stylesheet code as above just causes issues on some hosting providers and I can make an alteration to the styles that just do not show when i save the file, it does not matter how many times I refresh, hard refresh, clear caches, or swear at it, it just does not make the change.

Then all of a sudden after I have been refreshing and swearing for 10 minutes, then bam the new styles just start working.

I assume this is something to do with a caching server at the particular hosting provider, and to get around it I have to change my stylesheet link to this.

<link rel="stylesheet" type="text/css" href="/my-styles.css?<?php echo date('l jS \of F Y h:i:s A'); ?>">

My question is, is there any other way around this issue, like with an htaccess entry, php.ini, .user.ini, robots.txt, or something as it honestly drives my nuts, as it does the same thing with new images with the same filename not updating right away, as well as other files too.

Maybe there is a way to turn this all off at the host, I have already tried setting expires headers and ignoring certain file types in the .htaccess but it did not work, so maybe I did it wrong.

Community Page
Last updated: