How to reset css fonts cache

前端 未结 4 1680
野的像风
野的像风 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.

提交回复
热议问题