Jan 05 2008

Making Amazon Associates’ Product Preview link enhancer leave my server alone

Tags: , , , , , Filed under: Written in Englishhugo @ 21:47

I started writing music reviews in a new blog, as a way to fulfill my desire to discover new CDs and talk about them. I used to do this with Max, but now that we don’t meet regularly anymore, I’ve been missing it.

As I started doing this, I started playing with Amazon Associates, and discover their product preview link enhancer, which gives a nice little pop-up with Amazon info on a link to their site.

It shows up if you read a review and hover your mouse pointer over the shopping cart link of the album cover, and looks like this:

Amazon Product Preview screenshot

However, I noticed a huge slow down of my site as soon as I posted the 3 lines of JavaScript given by Amazon. Looking at what is happening with Firebug, a lot of bogus requests are done to my site, such as:

http://larve.net/2007/mublog/function%20(start,%20length)%20%7B%20%20%20%20start%20=%20start%20||%200;%20%20%20%20if%20(start%20%3C%200)%20{%20%20%20%20%20%20%20%20start%20=%20this.length%20+%20start;%20%20%20%20}%20%20%20%20length%20=%20length%20||%20this.length%20-%20start;%20%20%20%20var%20newArray%20=%20[];%20%20%20%20for%20(var%20i%20=%200;%20i%20%3C%20length;%20i++)%20{%20%20%20%20%20%20%20%20newArray[i]%20=%20this[start++];%20%20%20%20}%20%20%20%20return%20newArray;}

It looks like a typo somewhere. I wasn’t able to locate it, though. I looked around for hints, but couldn’t find anything. The issue is that each of those (and there are more than 10 on the front page) triggers WordPress processing, which takes quite a while and costs a lot of CPU cycles. It doesn’t look like an error on my end, since the instructions are pretty simple:

To put Product Previews on your site, paste the following link enhancer script at the end of pages on which you have image only or text only product links.

There’s little chance that I messed this up, so I ended up installing a work-around the hard way, by blocking all those requests with mod_rewrite:

# Blocking Amazon errors
RewriteRule ^(|.*/)function\ .*\( - [F,L]

That means that the pages are still causing bogus requests back to my server, but they are now processed in a much cheaper way and with a clear error.

I also contacted their customer support, hoping that they fix it soon.

Update: their customer support was not useful, but I figured out the root of the issue, thanks to the archive of the wp-hackers mailing list. It looks like Amazon’s Link Enhancer conflicts with ShareThis. Essentially, this is due to a JavaScript flaw, and Amazon’s code should be fixed. However, considering my first interaction with Amazon’s support and that this bug first showed up a year ago, I’m not too hopeful. As a work-around, I disabled ShareThis.

2 Responses to “Making Amazon Associates’ Product Preview link enhancer leave my server alone”

  1. Max says:

    We don’t meet regularly, but you’re still in my heart Hugo!

  2. Mike Blyth says:

    Thank you for proving I’m not going crazy! I have the exactly the same problem, asked Amazon why my pages were loading so slowly and taking about 1.5 MB each after I added the link-enhancer script, and like you got no help from Amazon. I didn’t bother analyzing more closely what was going on until today when I found what you found. Amazing that it has been noted for nearly 2 years and Amazon hasn’t fixed it! I’ll try your solution … thanks!

Leave a Reply

Please copy the string w3A2LT to the field below: