EN / ZH
Fixing WordPress Ajax Comments After Enabling Qiniu Cloud Storage or Upyun

In my previous article, Several Methods for CDN Acceleration with Qiniu Cloud Storage for WordPress Sites, many readers reached out with questions about Qiniu usage tips. One reader mentioned that after enabling Qiniu or Upyun, their blog’s comment system broke down and they had to resort to a third-party WordPress comment system. I suspect this is because some WordPress sites use Ajax-powered comments, and the comments-ajax.js file gets cached on Qiniu’s servers, causing the Ajax comment functionality to fail.

The fix is actually quite simple:
In the comments-ajax.js file, locate the following code block:

var i = 0,
    got = -1,
    len = document.getElementsByTagName('script').length;

while (i <= len && got == -1) {
    var js_url = document.getElementsByTagName('script')[i].src;
    got = js_url.indexOf('comments-ajax.js');
    i++;
}

Add the following line right after this block:
js_url = js_url.replace('aipsme.qiniudn.com','imzl.com');

Replace aipsme.qiniudn.com with your Qiniu subdomain or bound CDN domain, and replace imzl.com with your WordPress site’s domain. The same logic applies if you’re using Upyun.

After completing these steps, clear your Qiniu or other CDN service cache, and your WordPress blog’s Ajax comments should work normally again!