Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It seems the page cache never get's cleared for certain pages, explicitly a views page. I tested like this: decrease cache_lifetime to 1 minute, call "clear cache" and/or `drush php-eval "cache_clear_all();"` and wait a couple of minutes; no change for anonymous users at all :(
Relevant settings.php:
$conf['cache_backends'][] = './sites/all/modules/contrib/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
$conf['memcache_key_prefix'] = 'my_cache';
$conf['memcache_persistent'] = TRUE;
$conf['memcache_servers'] =
array('127.0.0.1:11211' => 'default',
'127.0.0.1:11212' => 'content',
'127.0.0.1:11213' => 'menu',
'127.0.0.1:11214' => 'views',
);
$conf['memcache_bins'] =
array('cache' => 'default',
'cache_page' => 'content',
'cache_entity_comment' => 'content',
'cache_entity_file' => 'content',
'cache_entity_node' => 'content',
'cache_entity_user' => 'content',
'cache_entity_taxonomy_term' => 'content',
'cache_menu' => 'menu',
'cache_views' => 'views',
'cache_views_data' => 'views',
);
$conf['page_cache_invoke_hooks'] = FALSE;
$conf['page_cache_without_database'] = TRUE;
#APC
/**
* Add APC Caching.
*/
$conf['cache_backends'][] = 'sites/all/modules/contrib/apc/drupal_apc_cache.inc';
$conf['cache_class_cache'] = 'DrupalAPCCache';
$conf['cache_class_cache_bootstrap'] = 'DrupalAPCCache';
Comment | File | Size | Author |
---|---|---|---|
#21 | d7_memcache.interdiff.txt | 1.29 KB | fago |
#21 | d7_memcache.patch | 4.38 KB | fago |
#18 | page_cache_without_database.patch | 4.66 KB | Jeremy |
#8 | drupal-bootstrap2.jpg | 134.66 KB | marcelovani |
#8 | drupal-bootstrap.doc_.zip | 111.9 KB | marcelovani |
Comments
Comment #1
cinnamon CreditAttribution: cinnamon commentedIt seems to work if I add this to the clear function for the cache_clear_all() part:
Is there any reason why the clear function should only work for the current user and only if variable cache_lifetime is set? At least this is how I read the current code:
Comment #2
Jarek Polok CreditAttribution: Jarek Polok commentedWe see same problem here, drupal 7.14, memcache 7.x-1.0.
Comment #3
paullomax CreditAttribution: paullomax commentedWe're having the same problem.
If you change
$conf['page_cache_without_database'] = TRUE;
to
$conf['page_cache_without_database'] = FALSE;
Then it works as expected.
But that will no doubt affect performance as Drupal does a bit more bootstrapping even if the page is cached.
I'm guessing it's because when it's set to TRUE, Drupal doesn't load the variables, and memcache is using a variable somewhere when grabbing cached pages?
(I believe the reason it doesn't flush the cache is because it would do this every time cron runs)
Comment #4
girishmuraly CreditAttribution: girishmuraly commentedTo confirm #3, when
$conf['page_cache_without_database'] = FALSE;
drupal bootstraps the variables, as can be seen here http://api.drupal.org/api/drupal/includes!bootstrap.inc/function/_drupal_bootstrap_page_cache/7Comment #5
ruedu CreditAttribution: ruedu commentedI think I'm seeing this exact same issue on our site. Pages cached for anonymous users won't expire. I tested #3 and it doesn't appear to work on my end.
Comment #6
girishmuraly CreditAttribution: girishmuraly commentedThe following sort of works for us ('sort-of' because we have other settings & are not sure if this is the real fix). Would be good to get confirmation if it helps others. Basically we found that drupal was not setting the correct expiry via memcache as it relied on the 'Expires' header in drupal_page_set_cache
Put this into a module:
Flush all cache & memcache and try again.
Comment #7
xavier_g CreditAttribution: xavier_g commentedHello,
Here is how I understand this bug, or at least the impact of cache_page_without_database:
and here lies the problem: since it is stored as a standard Drupal variable (and potentially cached in another bin, by another cache class or even not cached at all), it is theoretically unreachable without connecting to the database and bootstrapping the variables, even though it is potentially still available within Memcached.
Still, I wonder whether some or all of the variables mentioned in MemCacheDrupal::reloadVariables() could be systematically stored into Memcached, without any dependency to Drupal variables. Another approach consists in trying to load variables from Memcached, and connecting to the database only if it fails...
P.S.: by the way, in the code quoted by #3, shouldn't it be $cache_bins instead of $cache_tables?
Comment #8
marcelovaniI am attaching a fluxogram of what happens during bootstrap, which means, the variables get loaded during phase 3
Also, attaching a DOC version with links to the actual code and another fluxogram of how memcache works.
ps: all of these are todo only with page cache, other areas of caching havent been covered
Comment #9
cinnamon CreditAttribution: cinnamon commentedPS it seems APC caching was causing some additional troubels in our case, that is with APC caching we were completely unable to flush the cache when needed. For example after a theme upgrade.
At the moment we are using the memcache module in production again.
Comment #10
andyhu CreditAttribution: andyhu commentedI've seen the same issue as well. When using `drush cc all`, the cache isn't cleared. It seems not just for page cache but all caches handled by memcache is not cleared.
Comment #11
marcelovani@andyhu have a look at this http://drupal.org/node/1279654#comment-6473782
Comment #12
giorgio79 CreditAttribution: giorgio79 commentedMaybe an integration with http://drupal.org/project/expire would help...
Comment #13
gstout CreditAttribution: gstout commentedWill this work for d6?
Comment #14
stompeduns CreditAttribution: stompeduns commentedComment out:
Comment #15
yelgulwa CreditAttribution: yelgulwa commentedHello,
I am facing a similar problem but I am not sure if the cause is cached variables. Let me explain the symptoms.
* Core - 7.22 Memcache - 7.x-1.0
* When a new article is added, it never appears in a views stream after the cache lifetime.
* I set it to 1 min but it takes much longer to appear unless the cache is explicitly cleared.
* Two particular bins (bootstrap and filter) are dangerously full (close to 99%) and there are 0 evictions from there.
It would be great if someone facing similar issues could post some suggestions.
Thank you,
Swati
Comment #16
fagoBumping to major as this affects everyone who uses memcached for page cache and has page_cache_without_database set to TRUE.
Comment #17
Jeremy CreditAttribution: Jeremy commentedDuplicated; agreed it's a major bug. Assigning to myself to fix.
Comment #18
Jeremy CreditAttribution: Jeremy commentedPlease test the attached.
Comment #19
catchThis adds a bit of extra overhead with this setting compared to not having it, but I can't think of another option except storing that information outside the variables system altogether - and that'd still be an extra round trip.
Since we only care about a couple of variables here, what about just picking those out rather than the foreach() over all variables?
Comment #20
Jeremy CreditAttribution: Jeremy commentedThis extra loop only happens when page_cache_without_database is TRUE -- when it's FALSE, this loops still happens but in bootstrap.inc while bootstrapping variables.
I'd not expect this to have a measurable impact, except perhaps on a website with a massive $conf array... and IMO that's a user error anyways. Further, the variables we care about are not static (they depend on configuration), and figuring out on each bootstrap which variables are required is likely comparable overhead -- again, except in the case of an over-sized $conf array.
I suppose the thing to do here is to set up a load test and compare...
Comment #21
fagoYes, I do not see a performance problem with this loop either. It's the usual loop keeping $conf overrides and won't affect installations without the variable set.
Attached is an updated patch with variable namings that make more sense to me and some comments explaining whats going on. Then, I removed the manual call to _drupal_bootstrap_page_cache() - not sure why we'd need that?
Patch seems to do its job for me and offers the same performance as before, but with working cache clears.
Comment #22
Jeremy CreditAttribution: Jeremy commentedThanks, fix committed:
http://drupalcode.org/project/memcache.git/commit/a534d3d
I'd hoped for more confirmation from testers; I'll roll a Beta to make this easier.
Comment #24
drasgardian CreditAttribution: drasgardian commentedIf using APCCache for cache_class_cache_bootstrap (as per #14), this problem still persists when clearing caches with drush.
This is because drush can't clear the APC cache, as discussed here: https://www.drupal.org/node/1565716
Can work around this by commenting out this line in settings.php
Comment #25
znerol CreditAttribution: znerol commentedFollowup for Authcache: #2361001: Page cache never expires if authcache_builtin_cache_without_database is enabled