How to reset css fonts cache

前端 未结 4 1677
野的像风
野的像风 2021-01-18 01:06

I\'ve changed my fonts in the server, but the browser get the old version of the css file where fonts are writed, how to reset the cache?, i\'ve tried to delete browser cach

相关标签:
4条回答
  • 2021-01-18 01:40

    Make sure your browser isn't displaying local fonts — I spent almost one hour trying to figure out how to clear the font cache in Firefox, while the issue had nothing to do with that.

    Check your webserver logs : are font files downloaded ? If not, then it's likely you're using local fonts.

    Consider this real case scenario :

    @font-face{
        font-family: SuperFont;
        src: url('../fonts/Superfont.ttf'),
    }
    

    I copypasted this code from somewhere, removing part of the src definition, not noticing the ending comma which made this line invalid CSS. Therefore the font was not downloaded.

    However, since I had Superfont already installed locally, it seemed to work because the browser recognized the font-family. Well, until I decided to change the font file, but keeping the font-family definition to spare further modifications of the CSS file…

    Morality : when testing fonts, use an unambiguous custom font-family name.

    0 讨论(0)
  • 2021-01-18 01:42

    I've noticed this happen only in Firefox, which is very annoying, however, if this is the same situation as you here, refresh with SHIFT + CMD + R (if you're on a mac, I presume the windows alternative is CTRL + SHIFT + R)

    That'll clear your cache for that page too + SHOULD show your fonts :)

    0 讨论(0)
  • 2021-01-18 01:54

    Have you tried viewing the page in a different browser to ensure the old font isn't still being added to the page?

    If you're still using the same CSS file, you can navigate to the CSS file and do a hard refresh on that Ctrl+F5.

    Also, I've found that closing the page completely before clearing your cache can help too!

    0 讨论(0)
  • 2021-01-18 01:56

    Do a : Ctrl + F5 on your browser

    0 讨论(0)
提交回复
热议问题