I'm trying to cache the pages of my website, which are responsive and show the same contents for Desktop and for Mobile, with the exception of the location of the AdSense units if the visit is from Desktop or from Mobile:

  • for Desktop, I place the first ad (a 728x90 banner) just under the page title
  • for Mobile, the first ad is a below-the-fold 300x250 unit

The rest of the HTML contents are identical, except the AdSense code for the first ad. So I cannot cache the pages and I must query the database with the consequent load increment.

I wondered if any of you had similar experiences. Would you place the same AdSense code (e.g. responsive units) for the first ad (for both Desktop and Mobile), just in the below-the-fold of the mobile pages?

1 Answer 1


If you want to display ad units based on mobile vs desktop - you can try using CSS media query that sets display: none on the ad unit to hide it. So you always have 2 ad units, but for desktop (wide screens) you hide below-the-fold 300x250 unit while for mobile (narrow screens) you hide the 728x90 banner.

  • Hi Mikita, thank you for the answer. Are the CSS media queries allowed by the Google AdSense Terms and Conditions?
    – Hookstark
    Commented Oct 10, 2020 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.