Stylesheet not updating

后端 未结 14 1216
一个人的身影
一个人的身影 2020-11-28 04:10

I am creating a website, but when I made changes to the stylesheet on my site, and I refreshed the site, none of the changes were there.

I tried to use the view sour

相关标签:
14条回答
  • 2020-11-28 04:47

    ![Clear Cache] Ctrl+Shift+Delete http://i.stack.imgur.com/QpqhJ.jpg Sometimes it’s necessary to do a hard refresh to see the updates take effect. But it’s unlikely that average web users know what a hard refresh is, nor can you expect them to keep refreshing the page until things straighten out. Here’s one way to do it:<link rel="stylesheet" href="style.css?v=1.1">

    0 讨论(0)
  • 2020-11-28 04:48

    I ran into this problem too, a lot of people seem to recommend force reloading your page, which won't fix the issue in cases such as if you're running it on a server. I believe the optimal solution in this scenario is to timestamp your css.

    1. This is how I do it in my Django template:

    <link rel="stylesheet" href="{% static 'home/radioStyles.css' %}?{% now 'U' %}" type="text/css"/>

    Where adding ?{% now 'U' %} to the end of your css file would fix this issue.

    1. How you would do it with just CSS (hopefully someone edits this to a cleaner version, this looks a little janky but it does work, tested it):

    <link rel="stylesheet" type="text/css" href="style.css?Wednesday 2nd February 2020 12PM" />

    Where ?Wednesday 2nd February 2020 12PM (current date) seems to fix the issue, I also noticed just putting the time fixes it too.

    0 讨论(0)
  • 2020-11-28 04:52

    I had same issue. One of the reasons was, my application was cached and I was performing local build.

    I would prefer deleting the css file and re-adding it again with changes if none of the above comments work.

    0 讨论(0)
  • 2020-11-28 04:53

    I had a similar problem, made all the more infuriating by simply being very SLOW to update. I couldn't get my changes to take effect while working on the site to save my life (trying all manner of clearing my browser cache and cookies), but if I came back to the site later in the day or opened another browser, there they were.

    I also solved the problem by disabling the Supercacher software at my host's cpanel (Siteground). You can also use the "flush" button for individual directories to test if that's it before disabling.

    0 讨论(0)
  • 2020-11-28 04:54

    This may not have been the OP's problem, but I had the same problem and solved it by flushing then disabling Supercache on my cpanel. Perhaps some other newbies like myself won't know that many hosting providers cache CSS and some other static files, and these cached old versions of CSS files will persist in the cloud for hours after you edit the file on your server. If your site serves up old versions of CSS files after you edit them, and you're certain you've cleared your browser cache, and you don't know whether your host is caching stuff, check that first before you try any other more complicated suggestions.

    0 讨论(0)
  • 2020-11-28 04:54

    Don't update the styles in style.css, instead create a new stylesheet of your own and import in style.css

    your-own-style.css
          .body{
               /*any updates*/
           }
    

    import your-own-style.css in style.css

    @import url("your-own-style.css");
    
    0 讨论(0)
提交回复
热议问题