Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 网页的字体缓存_Css - Fatal编程技术网

Css 网页的字体缓存

Css 网页的字体缓存,css,Css,在CSS中,可以指定如下外部字体: <style type="text/css"> @font-face { font-family: "My Custom Font"; src: url(http://www.example.org/mycustomfont.ttf) format("truetype"); } p.customfont { font-family: "My Custom Font", Verdana, Tahoma; } </sty

在CSS中,可以指定如下外部字体:

<style type="text/css">
@font-face {
    font-family: "My Custom Font";
    src: url(http://www.example.org/mycustomfont.ttf) format("truetype");
}
p.customfont { 
    font-family: "My Custom Font", Verdana, Tahoma;
}
</style>
<p class="customfont">Hello world!</p>

@字体{
字体系列:“我的自定义字体”;
src:url(http://www.example.org/mycustomfont.ttf)格式(“truetype”);
}
p、 自定义字体{
字体系列:“我的定制字体”,Verdana,Tahoma;
}

你好,世界

如果用户在下载字体后失去Internet连接,网页是否仍会使用缓存版本的字体?即使存在,缓存是否会在到期日后的某个时间点将其删除?

这是一个相当通用的“解决方案”。有一个生产服务,已经运营多年,向公众开放(尽管检查他们的商业使用条款,我不知道是否合适)。这是美国联邦政府资助的内容分发网络研究项目

例如,它被称为Coral,其工作原理是将.nyud.net附加到任何URL

变成

。 没有别的事可做了。在第一个请求中,Coral服务器获取并缓存文件(预计会有一些延迟),然后在不再次检查的情况下为其提供服务(它们只偶尔检查新版本)


它使用的是一个高级DNS扩展名DNAME records,因此它可能无法与非常旧的操作系统或DNS解析程序一起工作,尽管已知任何合理的最新版本都可以工作。通过这种方式,请求被路由到地理位置相近的服务器。

但是如果缓存版本过期,它们仍然可以看到页面,但页面可能会恢复为使用系统字体。为什么不呢。浏览器被设计来处理他们不理解的缺失内容,比如自定义html元素,甚至忽略缺失文件之类的内容。仅仅因为缺少自定义字体并不是不显示页面的理由。我相当肯定这不是真的。许多组件都有一个有效期,您可以使用工具看到这一点。