Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/application-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Keep in mind following restrictions:
- `auction.preferredmediatype.<bidder>.<media-type>` - <media-type> that will be left for <bidder> that doesn't support multi-format. Other media types will be removed. Acceptable values: `banner`, `video`, `audio`, `native`.
- `auction.privacysandbox.cookiedeprecation.enabled` - boolean that turns on setting and reading of the Chrome Privacy Sandbox testing label header. Defaults to false.
- `auction.privacysandbox.cookiedeprecation.ttlsec` - if the above setting is true, how long to set the receive-cookie-deprecation cookie's expiration
- `auction.cache.enabled` - enables bids caching for account if true. Defaults to true.
- `privacy.gdpr.enabled` - enables gdpr verifications if true. Has higher priority than configuration in
application.yaml.
- `privacy.gdpr.eea-countries` - overrides the host-level list of 2-letter country codes where TCF processing is applied
Expand Down
15 changes: 12 additions & 3 deletions src/main/java/org/prebid/server/auction/ExchangeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@
import org.prebid.server.proto.openrtb.ext.request.ExtUser;
import org.prebid.server.proto.openrtb.ext.response.ExtBidPrebidMeta;
import org.prebid.server.settings.model.Account;
import org.prebid.server.settings.model.AccountAuctionConfig;
import org.prebid.server.settings.model.AccountCacheConfig;
import org.prebid.server.util.HttpUtil;
import org.prebid.server.util.ListUtil;
import org.prebid.server.util.PbsUtil;
Expand Down Expand Up @@ -241,7 +243,7 @@ private Future<AuctionContext> runAuction(AuctionContext receivedContext) {

final List<SeatBid> storedAuctionResponses = new ArrayList<>();
final BidderAliases aliases = aliases(bidRequest, account);
final BidRequestCacheInfo cacheInfo = bidRequestCacheInfo(bidRequest);
final BidRequestCacheInfo cacheInfo = bidRequestCacheInfo(bidRequest, account);
final Map<String, MultiBidConfig> bidderToMultiBid = bidderToMultiBids(bidRequest, debugWarnings);
receivedContext.getBidRejectionTrackers().putAll(makeBidRejectionTrackers(bidRequest, aliases));

Expand Down Expand Up @@ -311,12 +313,18 @@ private static ExtRequestTargeting targeting(BidRequest bidRequest) {
return prebid != null ? prebid.getTargeting() : null;
}

private static BidRequestCacheInfo bidRequestCacheInfo(BidRequest bidRequest) {
private static BidRequestCacheInfo bidRequestCacheInfo(BidRequest bidRequest, Account account) {
final Boolean cachingEnabled = Optional.ofNullable(account)
.map(Account::getAuction)
.map(AccountAuctionConfig::getCache)
.map(AccountCacheConfig::getEnabled)
.orElse(true);

final ExtRequestTargeting targeting = targeting(bidRequest);
final ExtRequestPrebid prebid = PbsUtil.extRequestPrebid(bidRequest);
final ExtRequestPrebidCache cache = prebid != null ? prebid.getCache() : null;

if (targeting != null && cache != null) {
if (cachingEnabled && targeting != null && cache != null) {
final boolean shouldCacheBids = cache.getBids() != null;
final boolean shouldCacheVideoBids = cache.getVastxml() != null;
final boolean shouldCacheWinningBidsOnly = !targeting.getIncludebidderkeys()
Expand Down Expand Up @@ -345,6 +353,7 @@ private static BidRequestCacheInfo bidRequestCacheInfo(BidRequest bidRequest) {
.build();
}
}

return BidRequestCacheInfo.noCache();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,6 @@ public class AccountAuctionConfig {

@JsonProperty("paaformat")
PaaFormat paaFormat;

AccountCacheConfig cache;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.prebid.server.settings.model;

import lombok.Builder;
import lombok.Value;

@Builder(toBuilder = true)
@Value
public class AccountCacheConfig {

Boolean enabled;
}
42 changes: 42 additions & 0 deletions src/test/java/org/prebid/server/auction/ExchangeServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
import org.prebid.server.settings.model.AccountAlternateBidderCodesBidder;
import org.prebid.server.settings.model.AccountAnalyticsConfig;
import org.prebid.server.settings.model.AccountAuctionConfig;
import org.prebid.server.settings.model.AccountCacheConfig;
import org.prebid.server.settings.model.AccountEventsConfig;
import org.prebid.server.spring.config.bidder.model.CompressionType;
import org.prebid.server.spring.config.bidder.model.Ortb;
Expand Down Expand Up @@ -1635,6 +1636,47 @@ public void shouldCallBidResponseCreatorWithWinningOnlyTrueWhenIncludeBidderKeys
.containsOnly(true);
}

@Test
public void shouldCallBidResponseCreatorWithCachingDisabledWhenCachingIsNotEnabledOnAccountLevel() {
// given
givenBidder("bidder1", mock(Bidder.class), givenEmptySeatBid());

final Bid thirdBid = Bid.builder().id("bidId3").impid("impId3").price(BigDecimal.valueOf(7.89)).build();
givenBidder("bidder2", mock(Bidder.class), givenSeatBid(singletonList(givenBidderBid(thirdBid))));

final ExtRequestTargeting targeting = givenTargeting(false);

final BidRequest bidRequest = givenBidRequest(asList(
// imp ids are not really used for matching, included them here for clarity
givenImp(singletonMap("bidder1", 1), builder -> builder.id("impId1")),
givenImp(Map.of("bidder1", 1, "bidder2", 2), builder -> builder.id("impId2"))),
builder -> builder.ext(ExtRequest.of(ExtRequestPrebid.builder()
.targeting(targeting)
.cache(ExtRequestPrebidCache.of(ExtRequestPrebidCacheBids.of(53, true),
ExtRequestPrebidCacheVastxml.of(34, true), true))
.auctiontimestamp(1000L)
.build())));

// when
target.holdAuction(givenRequestContext(
bidRequest,
Account.builder()
.id("accountId")
.auction(AccountAuctionConfig.builder()
.events(AccountEventsConfig.of(true))
.cache(AccountCacheConfig.builder().enabled(false).build())
.build())
.build()));

// then
final ArgumentCaptor<AuctionContext> auctionContextArgumentCaptor =
ArgumentCaptor.forClass(AuctionContext.class);
verify(bidResponseCreator).create(
auctionContextArgumentCaptor.capture(),
eq(BidRequestCacheInfo.noCache()),
eq(emptyMap()));
}

@Test
public void shouldCallBidResponseCreatorWithWinningOnlyFalseWhenWinningOnlyIsNull() {
// given
Expand Down
Loading