ubyssey / ubyssey.ca

The code that powers www.ubyssey.ca
GNU General Public License v2.0
35 stars 40 forks source link

Caching can deliver the wrong ad size on article page #1412

Closed SamuelmdLow closed 4 months ago

SamuelmdLow commented 4 months ago

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

SamuelmdLow commented 4 months ago

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

SamuelmdLow commented 4 months ago

Finally fixed it by moving the decision to javascript!

psiemens commented 4 months ago

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