数据URI和缓存 [英] Data-URI's and caching

查看:187
本文介绍了数据URI和缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在维基百科上阅读


数据URI不会与其包含的文档(例如CSS或HTML文件)单独缓存,因此每次包含文档重新下载时都会下载数据。

Data URIs are not separately cached from their containing documents (e.g. CSS or HTML files) so data is downloaded every time the containing documents are redownloaded.

这是否意味着我的代码是每次刷新页面或用户点击导航链接时下载的?我可以做什么来缓存数据uri的?

Does this mean that my code is downloaded every single time a page is refreshed or whenever the user clicks on a navigation link? What can I do to cache the data-uri's?

ps - 我只是谈论大约20个小的png文件(大多是丝绸图标,但2 * 16KB文件井)

ps - i'm just talking about 20 or so small png files (mostly silk icons but 2 * 16KB files as well)

推荐答案

数据URI只是以Base64编码的二进制数据形式的文本,嵌入在HTML和CSS文件。所以是的,每次他们被请求时,他们将被下载为您的HTML和CSS文件的一部分,除非这些文件本身被缓存。

Data URIs are nothing more than text in the form of Base64-encoded binary data, that's embedded within your HTML and CSS files. So yes, they will be downloaded as part of your HTML and CSS files every time they're requested, unless those files are themselves cached.

如果你保留你的数据URI只要你的样式表和发送适当的缓存头,缓存你的数据:图像与您的CSS应该不会造成问题。

If you keep your data URIs to just your stylesheets and send proper cache headers, caching your data: images together with your CSS shouldn't pose issues.

这篇关于数据URI和缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆