Data-URI's and caching

前提是你 提交于 2019-11-29 11:58:30

问题


I read this on Wikipedia:

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.

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 - i'm just talking about 20 or so small png files (mostly silk icons but 2 * 16KB files as well)


回答1:


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.

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.



来源:https://stackoverflow.com/questions/4791807/data-uris-and-caching

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!