Mark Jaquith‘s presentation on Confident Commits, Delightful Deploys brought up something which I didn’t thought of, “CDN proxies everything including dynamic php pages”.
In his example, he pointed out cdn.wpengine.com and wpengine.com, cdn.page.ly and page.ly, cdn.zippykid.com and zippykid.com are all serving the same content with their CDN counterpart.
So out of curiosity, I tested mine, cdn.lesterchan.net and lesterchan.net, and I have the same problem! I did not link it because I have already fixed the problem before writing this blog post.
A common link between us are our CDNs are hosted by NetDNA. So I wrote to them asking is there anywhere I can solve this. They recommended me their EdgeRules add-on which provides a powerful method of controlling how edge servers interact with content and websites visitors.
I gave it a try and it works! What I did was to only allow URI with file extensions to be served by the CDN as shown in the screenshot below:

Match Type: Default
Directive: REWRITE RULE ^(.*)$ https://lesterchan.net$1 permanent
Conditional: $uri != RegEx (Case In-Sensitive) .(png|jpe?g|gif|ico|html|txt|css|js)$
Rule Status: Active
Purge All Files: Yes

It is a bit “hack-ish” but I guess it will do for now.
A proper way which Mark Jaquith mentioned was to CNAME the CDN to something like static.yourdomain.com and have that subdomain serve only static files.
If you can have multiple rules, you could also explicitly whitelist your /wp-content/ directory. Pretty cool that you can define rules that run at the CDN level! Is this strictly a “call us for pricing” add-on?
Yeap, you can have Multiple Rules! (added another screenshot of the main page)
NetDNA right now is for enterprise and for the add-on is about USD$500. They are bringing to the consumers in MaxCDN soon, I am guessing the price should be around 1/10 of it =D
@lesterchan:disqus great write up! Email me as well I want to ask you a few questions about EdgeRules.
Done!
@markjaquith:disqus email me jdorfman at maxcdn and I will enable it for your account. Free of charge.