Skip to content

Commit

Permalink
Prebid Core: Add ttl buffer to videoCache.js (#8861)
Browse files Browse the repository at this point in the history
* Update videoCache.js

* Update videoCache.js

* Update videoCache_spec.js

* Update videoCache_spec.js

* master into ttl-buffer (#8869)

* Update Sonobi adapter with GVLID (#8860)

* dgkeyword RTD provider: fix tests causing ID5 test failures (#8862)

Co-authored-by: Mike Miller <mike@solitaired.com>
Co-authored-by: Demetrio Girardi <dgirardi@prebid.org>

* Revert "master into ttl-buffer (#8869)" (#8879)

This reverts commit b253980.

* Name the constant

Co-authored-by: Mike Miller <mike@solitaired.com>
Co-authored-by: Demetrio Girardi <dgirardi@prebid.org>
  • Loading branch information
3 people authored Aug 23, 2022
1 parent 47c8ead commit 73c13cd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
10 changes: 8 additions & 2 deletions src/videoCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import { ajax } from './ajax.js';
import { config } from './config.js';
import {auctionManager} from './auctionManager.js';

/**
* Might be useful to be configurable in the future
* Depending on publisher needs
*/
const ttlBufferInSeconds = 15;

/**
* @typedef {object} CacheableUrlBid
* @property {string} vastUrl A URL which loads some valid VAST XML.
Expand Down Expand Up @@ -63,11 +69,11 @@ function wrapURI(uri, impUrl) {
function toStorageRequest(bid, {index = auctionManager.index} = {}) {
const vastValue = bid.vastXml ? bid.vastXml : wrapURI(bid.vastUrl, bid.vastImpUrl);
const auction = index.getAuction(bid);

const ttlWithBuffer = Number(bid.ttl) + ttlBufferInSeconds;
let payload = {
type: 'xml',
value: vastValue,
ttlseconds: Number(bid.ttl)
ttlseconds: ttlWithBuffer
};

if (config.getConfig('cache.vasttrack')) {
Expand Down
14 changes: 7 additions & 7 deletions test/spec/videoCache_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ describe('The video cache', function () {
puts: [{
type: 'xml',
value: vastXml1,
ttlseconds: 25,
ttlseconds: 40,
key: customKey1
}, {
type: 'xml',
value: vastXml2,
ttlseconds: 25,
ttlseconds: 40,
key: customKey2
}]
};
Expand Down Expand Up @@ -205,15 +205,15 @@ describe('The video cache', function () {
puts: [{
type: 'xml',
value: vastXml1,
ttlseconds: 25,
ttlseconds: 40,
key: customKey1,
bidid: '12345abc',
aid: '1234-56789-abcde',
bidder: 'appnexus'
}, {
type: 'xml',
value: vastXml2,
ttlseconds: 25,
ttlseconds: 40,
key: customKey2,
bidid: 'cba54321',
aid: '1234-56789-abcde',
Expand Down Expand Up @@ -276,7 +276,7 @@ describe('The video cache', function () {
puts: [{
type: 'xml',
value: vastXml1,
ttlseconds: 25,
ttlseconds: 40,
key: customKey1,
bidid: '12345abc',
bidder: 'appnexus',
Expand All @@ -285,7 +285,7 @@ describe('The video cache', function () {
}, {
type: 'xml',
value: vastXml2,
ttlseconds: 25,
ttlseconds: 40,
key: customKey2,
bidid: 'cba54321',
bidder: 'rubicon',
Expand All @@ -309,7 +309,7 @@ describe('The video cache', function () {
puts: [{
type: 'xml',
value: expectedValue,
ttlseconds: 25
ttlseconds: 40
}],
});
}
Expand Down

0 comments on commit 73c13cd

Please sign in to comment.