문제

Following the advice on google's pagespeed addon, I moved my static content (images, css, javascript files) to a subdomain of my site on which there should be no cookies, thus saving some space in the request headers for each request for these files. However, on looking at the results I find that cookies are still being created for this sub domain. I have google adsense on my site and it is writing cookies to the root domain *.example.com rather than only to www.example.com

Is there any way to force adsense to write cookies only to the exact domain used for displaying the adds and not to the root domain?

도움이 되었습니까?

해결책

There appears to be no way to force adsense to create cookies for only a specific subdomain. The generally used solution is to simply serve your content from an entirely different domain. SO uses sstatic.net, Yahoo uses yimg.com, Youtube uses ytimg.com.

I'd recommend just getting a new domain name. It's only $10 a year or so (depending on your TLD). The ROI of that is, what, 10 minutes developer time?

다른 팁

There can be a proxy script -- a landing page -- where all the traffic for *.example.com lands and then request is dispatched to the intended subdomain. Alternatively, you can place that script in the each subdomains' root folder to redirect the adsense cookie to wwww.yourdomain.com. In Linux environment, it can be handled using .htaccess file, like:

# place this in your subdomain's root
RewriteEngine on
RewriteCond %{HTTP_COOKIE} ^.*SOME_ID=(\d+).*$ [QSA]
RewriteRule .* ../cache/$1 [QSA,L]

Where SOME_ID is a recurring name in each generated adsense cookie. <= This is to identify/ensure that the cookie under consideration is the adsense cookie.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top