Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data-URI's and caching

Tags:

css

data-uri

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)

like image 409
stephenmurdoch Avatar asked Jan 25 '11 09:01

stephenmurdoch


People also ask

Are data URIs cached?

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.

What is data URL format?

A Data URL is a string that starts with data: followed by the MIME type format. For example a PNG image has mime type image/png . This is followed by a comma and then by the actual data. Text is usually transferred in plain text, while binary data is usually base64 encoded.

What is the use of data URI?

A data URI is a base64 encoded string that represents a file. Getting the contents of a file as a string means that you can directly embed the data within your HTML or CSS code. When the browser encounters a data URI in your code, it's able to decode the data and construct the original file.

What is data text plain?

In computing, plain text is a loose term for data (e.g. file contents) that represent only characters of readable material but not its graphical representation nor other objects (floating-point numbers, images, etc.).


1 Answers

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.

like image 199
BoltClock Avatar answered Sep 20 '22 15:09

BoltClock