ubyssey/ubyssey.ca

Caching can deliver the wrong ad size on article page

Closed this issue · 3 comments

We could solve this by figuring out how to vary caching by user agent but I think it would be easier and best to just add both ad sizes to the template and display only the correct one based on display size, just like how the banners are done right now

There can only be one version of the ad because google replaces the elements with the id of the ad slot. So my solution of loading both mobile and desktop version does not work. Ads are not showing on mobile right now. To fix this I think we have to use javascript to judge which ad size to create and then load it

Finally fixed it by moving the decision to javascript!

Nice fix! Makes a lot of sense given that the rest of the ad loading happens on the client side anyways.