Skip to content

Local vast cache: only store bids that aren't cached remotely yet #14631

@robin-crazygames

Description

@robin-crazygames

When using the IMA player + GAM, passing an URL to the IMA player and letting the IMA player make the request to GAM still results in better revenue.

That is why, in the above case, using a hybrid approach is the best solution that doesn't require an external VAST cache:

  • When you have a winning prebid bid, you ask Prebid to contact GAM and download the VAST XML, and pass that to the IMA player using the getVastXml method
  • When you don't have a winning prebid bid, you ask Prebid for the GAM URL and let the IMA player do the request using the buildVideoUrl method

I want to be able to use the second approach (pass a GAM url to IMA, and let IMA do the request) when I have a winning prebid bid that doesn't need the local cache.

Currently that isn't possible because e.g. for Rubicon, when I receive a bid which contains

vastUrl: https://prebid-server.rubiconproject.com/cache?uuid=foo

the GAM URL I get from Prebid will contain

hb_uuid=bar
hb_uuid_rubicon=bar

where bar is a uuid from the local cache.

However, if at this point I would let the IMA player make the request, the replacing of bar with foo won't happen and the IMA player cannot download the VAST XML.
That forces me to use the getVastXml method instead of being able to use the buildVideoUrl method with the improved GAM auction.

I think this issue would need changes in 2 places:


Skip local storage when not needed:

export const storeLocally = (bid) => {
  //When the bid is already stored in a remote cache, no need to store it locally
  if(bid.vastUrl){
    return
  }
  const vastXml = getVastXml(bid);
  const bidVastUrl = URL.createObjectURL(new Blob([vastXml], { type: 'text/xml' }));

  assignVastUrlAndCacheId(bid, bidVastUrl);

  vastLocalCache.set(bid.videoCacheKey, bidVastUrl);
};

Only try replacing UUIDs in the bid when it is coming from the remote cache

In getVastForLocallyCachedBids, replace the

if (!vastAdTagUriElement || !vastAdTagUriElement.textContent) {
      return gamVastWrapper;
}

check with

if (!vastAdTagUriElement || !vastAdTagUriElement.textContent || !vastAdTagUriElement.textContent.startsWith(config.getConfig('cache.url'))) {
      return gamVastWrapper;
}

This relies on the cache.url being specified, but according to the docs, this is a required property anyway.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions