From what i can see in the sess_write function will always set the $user->cache to 0|zero since the $user will always start with an anonomous user.
The problem here with having $user->cache timestamp to always 0|zero, is that when
the evaluation in the cache_get function, will never evaluate to true, returning old cache data
even for authenticated users.
I refer to this part:
if ($user->cache > $cache->created) {
// This cache data is too old and thus not valid for us, ignore it.
return 0;
}
in the cache_get function http://api.drupal.org/api/function/cache_get.
One easy solution is to set the $user->cache = time() after the drupal_unpack($user) in the sess_read function in sessions.inc.
Comments
Comment #1
Anonymous (not verified) commentedSubscribing
Comment #2
catchMarking as duplicate ofhttp://drupal.org/node/277155 was duplciate, and bumping this to 7.x so it can be fixed there first.Comment #3
Anonymous (not verified) commentedActually marking it duplicate.
Comment #4
damien tournoud commentedThis is in fact the oldest issue.
About the issue itself: I guess this is by design. $user->cache is only used during a cache_clear_all() call to simulate that the cache has been flushed for the current user. Other users will still see old data until
cache_lifetimeseconds have been elapsed.I'm very tempted to mark that as 'by design', but others may want to comment.
Comment #5
deplifer commentedThis forces modules to use be dependent:
* on the
cache_clear_all()generally called only on a node insert/update/delete$op.* Or to have cron running, and purge the cache objects themself, which needs to be updated on a basis different than the cache_lifetime itself.
* Then it should also be clear in the
cache_setthat onlyCACHE_PERMANENT|CACHE_TEMPORARY, are working.This i not practical, since the
cache_clear_all().Forces alot of
cache objectsto be flushed at the same time, creating a heavy impact on the site if you have alot of stored cache objects.Therefore allowing the independent use of
unix timestamp, would allow that objects are updated independent of a call to thecache_clear_all()and that some of content(blocks) on the site are updated on a more regular basis. Then a call tocache_clear_all()is having a less heavier impact on the overall site, since not all objects are dependent on a call to this function.Comment #6
damien tournoud commentedThis would require a substantial rework of the minimum cache life architecture. Currently, the minimum cache life relies on cron (implementation details:
system_cron()callscache_clear_all()) to invalidate objects older thanexpire + minimum_cachelife. It will not work if there is no cron running.On the other hand your solution can't work because
$user->cacheis only meant to simulate that a call tocache_clear_all()has an immediate impact for the current user. Settign $user->cache to time() insess_read()would essentially remove all caching.Comment #7
deplifer commentedI agree but the only work around would be to change the
$expirevariable when it is set toCACHE_TEMPORARYfor thecache_set()function.The
CACHE_PERMANENTblock in thecache_getfunction is always evaluated before the$user->cache > $cache->created.This allows the authenticated user to have some
blocks, to be updated withoutcronor on a more reularg basis.The anonymous users would still receive the cached pages.
And when the
cache'd pageis expired some blocks of content which has already beencachedfor a authenticated user, wouldnt need to be rebuild if the authenticated user already has cached that section of the page.The code above would also make
cached pagesbe flushed on a more independent basis.Since say pages are cached for 30 minutes, then a page A could be cached 5 minutes before page B and also would be flushed 5 minutes before page B. If they are accessed on a regulary basis in those 30minutes.
Now say you have 10thousand pages or more flushed at the same time, and you have the same amount of anonymous and authenticated users accessing the pages that have been flushed at the same time or in a 1-3minutes intervall, this is spike which would be more normalised if the cache objects are flushed more or less on a independent basis with own timestamps.
Comment #8
damien tournoud commented@deplifer: I do agree that the management of cache_lifetime could be improved. But the current architecture is probably there for a reason and we need people more aware of the design constraints involved to comment on that.
I only wanted to make it clear that was you suggested in the first message is wrong. I suggest you open a separate issue to discuss improving the cache_lifetime management.
Comment #9
deplifer commented* Forum Topic ?
or
* Feature Request ?
Comment #10
damien tournoud commentedI suggest you open a feature request.
Comment #11
deplifer commentedhttp://drupal.org/node/277229