This has been reported by a few people, such as Frank.dev here:
If I activate the caching mode for the Drupal-site (Administer >> Site configuration >> Performance: Caching mode: "Normal"), it is indicated again generally the Adsense client ID of a user - revenue_sharing does not work.
All the same which setting I choose - "Percentage of node views going to author: 5 - 90" - it is always the same result. Either is indicated generally the Adsense client Id of the Site owner or the author.
If I disabled the cache, the indicated ID's alternate in the source correctly.
This is a known limitation. Page caching caches all the end result of HTML's page and serves it to the subsequent visitors. So, whatever the Adsense ID happens to be when the page got cached, this will be served to the visitors until the cache expires (duration expires, or new content/comment gets posted).
For now, the workaround is to disable caching, which is OK for sites that do not have a lot of taffic.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | rev_share_cache_1.patch | 11.8 KB | mpaler |
| #9 | revenue_sharing_basic-refresh.patch | 2.4 KB | Petra |
Comments
Comment #1
Petra commentedEvident.
You wrote:
What empties cache when I set a cache duration - and no content/comment is posted or edited?
Will drupal check cache time before he delivers the site? Or does cron check this and empties the cache when duration is expired?
(I thougt cache duration is only for high traffic sites. P.e. when every minute a comment is posted, I set a cache duration for 10 minutes. So cache will be emptied only every 10 minutes. But when I have a site where nothing changes over 3 days, cache will not be emptied before I edit or post some content/comment).
Will this be the same in drupal 6?
Comment #2
kbahey commentedPetra
The cache is expired either when new content/comment is posted (as well as other things, such as enabling modules, changing the menu, ...etc.), OR when the period expires.
If you set the cache to expire every 15 minutes, then even if you post a comment, the cache will not expire until 15 minutes has passed.
In any case, I committed a workaround for 5.x-2.x that displays a message in adsense settings if cache is enabled, and revenue sharing is enabled. It does not fix the problem, but at least tells the admin that things may not work.
A similar problem exists for using tags inside content with caching.
With the current design of Drupal, I don't think there will be a solution to this issue in adsense itself. It has to be at Drupal's level.
Comment #3
Petra commentedWhen drupal 6 will have the same cache mechanism, a solution would be fine.
My idea is to set cache duration to one hour - so every hour the dice rolls for the Adsense-Client-Id.
So I can enable cache and be sure that revenue is shared.
But what happens, if nothing is changed on a site for several days. Will cache be emptied or not?
I think cache mechanism works like I described here: http://drupal.org/node/142242#comment-235668
If I'm right and if nothing is changed on a site, there is no way for the Drupal core to know that cache has expired, and old content will be held in the cache.
So to be sure that cache is emptied after an hour, I have to write a module that uses hook_cron to call cache_clear_all(), described here: http://drupal.org/node/103995#comment-181373
and I have to run cron every hour. Right?
Comment #4
kbahey commentedRegardless of how the cache works, we can enforce a cache flush.
We don't even need cron for this. We can do it in hook_init() in revenue_sharing_basic.module or even adsense.module.
We store when did we last flush the cache, and say how often we should flush, then when a page view comes in we check that and flush if X minutes have passed, regardless of how often cron runs.
This can be in adsense.module advanced settings.
What do you think?
Comment #5
Petra commentedI think it's a valid method for revenue sharing to throw the dice for the Adsense ID every X minutes. So it can go into the module.
And I think it's a good solution to the cache problem. It also could be an example to solve the similar problem using tags inside content with caching.
It should go into revenue_sharing_basic.module, cause it's only needed for revenue sharing:
--Revenue sharing options--
X Enable revenue sharing
Note that enabling this will disable AdSense code caching, which~ Note that revenue sharing is not working reliably when cache is enabled. Disabling cache can cause more resource usage for busy sites. The referral feature requires the referral module to be installed.
(or did you really disable caching?)
Enforce cache flush
0-X minutes
~ If cache is enabled, you can flush the cache to throw the dice for the Adsense ID...
+ a hint what happens, if cache duration is enabled
Percentage of node views going to author:
50
Comment #6
kbahey commentedI revised this part, and it seems OK:
This part needs better rewording. Can someone please suggest better English wording?
Comment #7
funana commented+1
A solution for this is needed!
*subscribing
Comment #8
kbahey commentedAnyone wants to contribute a patch?
The patch should do what I described in #4: we have a function revenue_sharing_init() and we check the last time the refresh was done, and check the option (below) and refresh the cache every X minutes:
The settings would have a new option like so:
And we need REVENUE_SHARING_REFRESH_INTERVAL to be set above in the settings.
Please revise the wording.
Can anyone submit a patch for this?
Comment #9
Petra commentedHere is a patch. But it does not work: revenue_sharing_basic_init() is not called for anonymous users - only when I'm logged in.
I don't know how to fix this.
(I added 45 minutes cause min-cache-duration also has this option.)
Comment #10
kbahey commentedPetra, are you using aggressive caching or normal caching?
Comment #11
Petra commentedkbahey, I use normal caching.
And I see the notice: "The following enabled modules are incompatible with aggressive mode caching and might not function properly: path_redirect, revenue_sharing_basic, token."
Comment #12
summit commentedSubscribing, I will test adsense 2.dev with revenue sharing, greetings, Martijn
Comment #13
Petra commentedCan I do something to solve this issue? Please, let me know.
Comment #14
drupalina commentedsubscribing
(a small comment: GoogleAds generates income only on relatively high-traffic sites And the speed of pageloads in essential. So it makes sense to have a caching compatibility for Revenue Sharing. I tried Revenue Sharing, but had to disable it _only_ because disabling my Normal caching made my pageloads slower and very user-unfriendly)
Comment #15
jcnventuraThis seems to be impossible to handle.. If Drupal's cache is enabled, then it will store an 'image' of the page when it last served it, and it will keep re-using that page from cache until it expires or the page is modified.
The only way to make this work would be to invalidate the cache all the time. Which would make it useless to have cache enabled in the first place.
This can be reactived later on if someone finds a way to modify a page after it is retrieved from the cache, but before being sent to the user's browser.
Comment #16
mpaler commentedWill using ajax solve this problem?
Comment #17
mpaler commentedHi,
I believe I've solved this problem for cached pages by using ajax. I've tested and it works on normally cached pages. Attached is a patch for review.
In a nutshell here's how it works:
1. If user is anonymous, in the adsense_display function (adsense.module) we run a different function:
2. In the new function, _adsense_oldcode_get_ad_anon, we insert some js inline into the header that will create an ajax call back to revenue_sharing_basic.module to fetch the publisher id and set it as a global js variable.
In this same function, when we embed the google embed code, we reference the global js variable as follows:
3. Created a new menu callback in revenue_sharing_basic.module (called by the ajax above). This in turn calls a slightly modified revenue_sharing_basic_choose_client function that now accepts node_id as an optional argument and returns a json formatted publisher id.
I've also added an administration testing setting that let's you see the publisher_id that get's returned.
Some important points.
1. Patch is rolled against the 5.x-3.x-dev 2009-Sep-02 release
2. This whole routine only works if you are logged out.
3. This setup requires that all of your js be loaded in the head of your page. Otherwise the google ad embed will load first and reference an undefined variable.
Feedback is welcome though my time is very limited at the moment.
Comment #18
jcnventuraHi,
The 'adsense_anonymous_test_mode' setting is completely unnecessary, the existing 'adsense_test_mode' is completely adequate for this also.
Why does the new function duplicate all the existing ad generating code from the managed ads module? Why aren't you re-using that code?
Finally, there's too much duplication inside revenue_sharing_basic_get_node_info().. I think that modifying this function to always accept the $nid parameter would improve the code a bit.
João
Comment #19
CarbonPig commentedsubscribe
Comment #20
jcnventuraThe solution for this should be something like the Ajax Blocks module.
Comment #21
pomliane commentedThis version of AdSense is not supported anymore. The issue is closed for this reason.
Please upgrade to a supported version and feel free to reopen the issue on the new version if applicable.
This issue has been automagically closed by a script.