Why is my CSS not Updating in Web Browser?

Being a developer I have face this issue a lot of times, so now writing this post so others can get help and save time of searching codes.

Their can be many reasons for your new CSS code is not getting updated on your website.

Method 1. Clear your browser cache and reload the page. (press ctrl + F5 key simultaneously) some times this won’t work you need to manually clear cache.

Method 2. If above don’t work, check your header file to confirm your CSS file on which you updated the code is present or not.

Method 3. If the file is present not it still does not reflect your new css code then try this

<link rel="stylesheet" href="style.css?v=1.1">

by adding version at end of your css file and now you can see your new code will reflect on browser. But for next time your add new css or modify existing you will again need to change the version from v=1.1 to v=1.2

Now this becomes 1 tough task to modify version again and again if you are continuously doing changes so here is the way just do this

<link rel="stylesheet" href="style.css?v=<?php echo time();?>">

Now we have added current time with your css file so when ever you update it, current time will be added to it and you just need to focus on your CSS code only.

If your site is on WordPress or any other CMS and you have installed any caching plugin on that then try clearing the cache from their as well.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: