Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm considering using the nginx template below for WP sites with adsense on them. Would that cache the adsense ads too and make the clicks invalid?

server {
listen      %ip%:%proxy_port%;
server_name %domain_idn% %alias_idn%;
error_log  /var/log/%web_system%/domains/%domain%.error.log error;

location / {
    proxy_pass      http://%ip%:%web_port%;

    proxy_cache cache;
    proxy_cache_valid 15m;
    proxy_cache_valid 404 1m;
    proxy_no_cache $no_cache;
    proxy_cache_bypass $no_cache;
    proxy_cache_bypass $cookie_session $http_x_update;

    location ~* ^.+\.(%proxy_extentions%)$ {
        proxy_cache    off;
        root           %docroot%;
        access_log     /var/log/%web_system%/domains/%domain%.log combined;
        access_log     /var/log/%web_system%/domains/%domain%.bytes bytes;
        expires        max;
        try_files      $uri @fallback;

location /error/ {
    alias   %home%/%user%/web/%domain%/document_errors/;

location @fallback {
    proxy_pass      http://%ip%:%web_port%;

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}

include %home%/%user%/conf/web/nginx.%domain%.conf*;


share|improve this question

Adsense resources are hosted on google's side, not yours.

share|improve this answer

Adsense earnings drop when you use caching programs. I've had it go from earning $300 a day to $3.00 a day and when I turned off caching it went right back up to $300. This guy above is mistaken for saying it cached on google's side not yours. Your caching plugins will cache the google code, and it will not count your views just your clicks.

share|improve this answer
If that happened to you, then you did something seriously wrong in your caching configuration. – Michael Hampton Feb 1 '15 at 22:11
adsense is just a script tag - the code doesn't change from one request to another, it makes no difference whatsoever whether it's in cached/a static html page or served dynamically. If you can provide something more substantial than FUD as to your particular scenario, it'd be possible to say what happened. Even with that though -1 for an anecdotal, easily refutable answer. – AD7six Feb 1 '15 at 22:17
Well I've provided the exact template code for a reason. So someone more knowledgable than me can say for sure if that would cache google adsense ads as well. From my understanding it will render the page once per 15 mins, and for the rest of those 15 mins will serve the same page as if it was static html. Is that right? – lixolumi Feb 2 '15 at 12:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.