Caching Mechanisms

Media files are loaded “on-the-fly” when they are needed for the first time. When downloaded, they are kept in the cache storage. When the storage runs out, the last used files are deleted first. How to ensure, that the file will play only if it is cached?

Prefetch

The SMIL prefetch introduce a preload mechanism. Prefetch loads a media into cache without playing it.

<prefetch src="https://domain.tld/video.mkv" />
video.mkv will download into cache

But we have also some more control over the caching.

Control the Cache Behavior

A parameter with the name cacheControl and a value control how the cache works. This is not standard SMIL, but useful. Player who not supported this feature should ignore it.

Values are:
  • noCache: This means the player will download the media every time.
  • onlyIfCached: The media will not displayed until it is completely downloaded in the cache storage. Some player will skip, if media is not in cache, even when a dur-attribute has a value.
  • auto: This is default and the same as onlyIfCached
<img src="https://domain.tld/0001.jpg" dur="2s">
   <param name="cacheControl" value="auto"/>
</img>
<img src="https://domain.tld/0002.jpg" dur="2s">
   <param name="cacheControl" value="onlyIfCached"/>
</img>
<img src="https://domain.tld/0003.jpg" dur="2s">
   <param name="cacheControl" value="noCache"/>
</img>
0001 and 0002 will skip. 0003 waits until download
Cacheable media are:

Websites, streams, and colors (brush) will not be cached.