Caching creatives
Keep each file on the device before its slot comes. These rules apply to every player, online or offline.
Download files early
Section titled “Download files early”- Call
GET /v1/ads?playerid=…&key=…&offline=trueon every boot and on a schedule. We recommend every 12 hours. Download every<MediaFile>that it returns. - Give each screen its own refresh time, so the screens of one site do not all download at once.
- Download the files in list order. We recommend one at a time, but parallel downloads are also correct.
- Keep playing stored ads while you refresh. On first boot, start playing as soon as the first file is downloaded.
- Store each file under its media URL.
- Delete a stored file 24 hours after the last refresh that listed it. If no refresh listed it, count from when you stored it. If the player cannot reach us, delete nothing.
Size the storage
Section titled “Size the storage”We recommend room for at least 100 ads of up to 50 MB each. If you have less room, delete the files lowest in the list first, or ask for fewer ads with limit. Do not size the storage from one response, because the number of ads can change. A <MediaFile> can have no fileSize.
Ask a little ahead
Section titled “Ask a little ahead”Request the online ad a little before its slot starts, not much earlier. Never play an online ad past its expires_at.
When the file is not there
Section titled “When the file is not there”Before you download an online ad’s file, check if it is stored under its media URL. If it is, play the ad as normal. If it is not, start the download. If the download is not done when the slot starts:
- Play a stored ad instead, chosen by the offline rules. Fire its tracking URLs as normal.
- Skip the online ad. You can fire its
<Error>URL with code402; see When an ad cannot play. - Let the download finish. Keep the file for the next ad that uses it.
Never leave the screen black. Never fire the <Impression> or <Tracking> URL of an ad that did not play.
When the player cannot refresh
Section titled “When the player cannot refresh”If the player cannot reach us and every stored ad is past its expires_at, keep playing the stored ads in turn. Fire their tracking URLs as normal. These plays are not billed. When a refresh works again, go back to normal.
If nothing is stored at all, show the player’s own default image and fire nothing for it.