CloudFlare and RocketLoader

CloudFlare and RocketLoader

The Problem

Web sites should be fast and to that end you have just set up CloudFlare to accelerate your web site. You pat yourself on the back and call it a day. However, the next day an upset advertiser rings you up and says their ads that are only supposed to be showing in New York are showing up to visitors in other locations! What gives!?!


The problem is that by default CloudFlare's RocketLoader will "accelerate" your third-party scripts. Where this becomes a problem is that RocketLoader hides your visitors IP address from AdvertServe. Not because they are being sneaky, but due to the fact that they don't implement X-Forwarded-For as you would expect when fetching the ads. Instead we are getting the IP address of one of their CDN servers and targeting ads to the location of said server.

Quick Solution

The quick solution is to simply change your CloudFlare settings and disable RocketLoader.

Alternate Solution

You really want to use RocketLoader though because you have your web site packed with all of the latest slow loading third-party widgets. Here is what you do. You need to edit all of the AdvertServe zone codes on your web site and change the <script> tags to look like this:

<script data-cfasync="false" type="text/javascript">

What we have added is the data-cfasync="false" part, which tells RocketLoader not to mess with it. We realize this would be a lot of work for you to do. You probably have hundreds or thousands or zone codes to edit. Complain to CloudFlare to get this problem fixed.

Incidentally, you really don't need to use something like RocketLoader with AdvertServe. We are the only ad server with complete built-in support for loading ads asynchronously. All you have to do is use our AJAX zone codes to take advantage of that. Doing so will give you all of the same benefits as using RocketLoader without impacting critical functionality like geographic targeting.

To be fair, RocketLoader does help lessen the impact of other third-party scripts and widgets that don't have asynchronous loading capabilities so it does have its place.

← Page Peel Ads
Wallpaper Ads →