Should I locally store CSS generated by the Google Web Fonts API?

后端 未结 3 1027
挽巷
挽巷 2021-02-12 19:49

I am using some Google Web Fonts. I hear that Google deal with all the issues between different browsers and serve different media depending on the browser in the request header

相关标签:
3条回答
  • 2021-02-12 19:58

    The CSS served up by Google Webfonts changes depending on the user agent in the HTTP request header, so you'd be better off using @import. The reason is the different implementations of web fonts in different browsers.

    0 讨论(0)
  • 2021-02-12 20:08

    Not an answer to your exact question, but even if it were possible at the moment, I would never locally cache any CSS that Google serves "live" because:

    • even if it works now, it may break later if they change something

    • you do not add any reliability, because the font itself still has to be fetched from Google

    • you do not really improve performance much: if everything is configured correctly, the HTTP request will happen only once and be cached thereafter. Also, the user may have the font CSS cached from another site that uses Google Fonts.

    0 讨论(0)
  • 2021-02-12 20:18

    If you want to store local CSS then you MUST store font locally too because otherwise it will again have an extra HTTP request.

    And Google allows downloading font for local usage but you can check for web too. https://developers.google.com/webfonts/faq

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