Home > database >  CSS file not getting updated for users
CSS file not getting updated for users

Time:12-31

i am hosting a website on hostinger and whenever i do a change in the CSS file it reflects the changes on some of my website users while it doesnt change for others, i figured it might be because it gets cached for some users..

I tried to add the "?v=1.0" at the end of the CSS file link to try to get the browser to reload the file for the users but there was no changes. Then i tried to change the WHOLE name of the CSS file and it worked for SOME users but still not for everyone. I tried to add CONTENT="NO CACHE" and it had no effect either. I also noticed that most of the problems are for users using Google Chrome..

Here is how i normally link my CSS file:

<link href="nav.css" rel="stylesheet" type="text/css" />

What i am looking for is that whenever i do a change in my CSS file it would get reloaded for all users and not stay on the old cached version since i dont want nor will it be effecient to ask users to clear their cache every time i make a change.

CodePudding user response:

Try to "Empty cache and hard reload" in the webbrowser. (CTRL F5 in your webbrowser)

CodePudding user response:

I'm unsure why versions don't work, so maybe someone more experienced can pitch in on that, but in the meanwhile you can use something like:

<link href="style.css?key=<?php echo time(); ?>" type="text/css" rel="stylesheet" />

This will, however, force the user to load the css upon every single visit to the site and affect your sites performance, so remove when the site goes live.

  • Related