The check_markup function has a one day expiration hard-coded:

      cache_set($id, 'cache_filter', $text, time() + (60 * 60 * 24));

rather than using the system's cache lifetime value:

      cache_set($id, 'cache_filter', $text, time() + variable_get('cache_lifetime', 86400);

I searched and could not find out why. This seems inconsistent.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ricabrantes’s picture

Status: Active » Closed (fixed)

No activity, Close..

NancyDru’s picture

Version: 6.0-beta4 » 6.0
Status: Closed (fixed) » Active

What activity do you want? I'd like to see someone explain this.

ainigma32’s picture

Version: 6.0 » 7.x-dev

Did you ever get an answer? I can see it's still in HEAD.

- Arie

NancyDru’s picture

No; it would seem that the only way to get this addressed is to submit a patch.

ainigma32’s picture

Status: Active » Needs review
FileSize
896 bytes

That sounds like a challenge ;-)

Patch attached. Let's see what people think.

- Arie

ainigma32’s picture

Category: support » bug

Still not much attention. Setting to bug report as this arguably is a bug.

- Arie

ainigma32’s picture

@NancyDru: Could you test this patch against HEAD so it can be set to RTBC ?

- Arie

NancyDru’s picture

I will have to do some tweaking. My D7 test site is built with a -dev version a few days old, so I will have to do a checkout, I guess. The code looks right.

dawehner’s picture

its make total sense, i also had the issue when writing a filter, that setting cache_lifetime didn't changed anything

BUT
every code in core uses cache_lifetime with default_value: 0

./modules/system/system.admin.inc:1352:  $form['page_cache']['cache_lifetime'] = array(
./modules/system/system.admin.inc:1355:    '#default_value' => variable_get('cache_lifetime', 0),
./modules/system/system.install:1144:        'description' => "The time of this user's last post. This is used when the site has specified a minimum_cache_lifetime. See cache_get().",
./modules/simpletest/tests/cache.test:99:    variable_set('cache_lifetime', $time);
./includes/cache.inc:22:  if ($cache_flush && ($cache_flush + variable_get('cache_lifetime', 0) <= REQUEST_TIME)) {
./includes/cache.inc:36:    if ($cache->expire == CACHE_PERMANENT || !variable_get('cache_lifetime', 0)) {
./includes/cache.inc:159:    if (variable_get('cache_lifetime', 0)) {
./includes/cache.inc:171:      elseif (REQUEST_TIME > ($cache_flush + variable_get('cache_lifetime', 0))) {

Here is the result of running the tests:
8138 passes, 0 fails, and 0 exceptions

dawehner’s picture

FileSize
938 bytes

here is the patch

Dries’s picture

Things that are run through check_markup should always be cached because we can always cache them -- there is no harm.

This patch can result in severe performance losses.

dawehner’s picture

FileSize
942 bytes

so here is a current patch with a default of 86400s

Status: Needs review » Needs work

The last submitted patch failed testing.

ainigma32’s picture

Status: Needs work » Needs review
FileSize
898 bytes

OK back to the original patch (rerolled) to get this issue moving again.

- Arie

ainigma32’s picture

FileSize
899 bytes

Added a comma to the comment (yes really) :-) per discussion with dereine on IRC.

- Arie

dawehner’s picture

FileSize
2.42 KB

i used this method of cache lifetime and replacing 24*60*60 with the calculated value 86400

hey you also removed the s from days ^^

sun’s picture

+    // Store in cache using the system's expiration time or an expiration time of 1 day if it is not set.

...should rather use "default" here. Also, no need to repeat "expiration". And, additionally, comments need to wrap at 80 chars.

-      cache_set($cache_id, $text, 'cache_filter', REQUEST_TIME + (60 * 60 * 24));
+      cache_set($cache_id, $text, 'cache_filter', REQUEST_TIME + variable_get('cache_lifetime', 86400));

Please revert to 60 * 60 * 24 instead of 86400. If we are going to change this, then we will change this everywhere in core (in a separate issue); changing it just here means inconcistency == bad.

sun’s picture

Status: Needs review » Needs work
ainigma32’s picture

FileSize
908 bytes

Rerolled and modified per #17

- Arie

ainigma32’s picture

Status: Needs work » Needs review

Could have sworn I set this...

- Arie

Status: Needs review » Needs work

The last submitted patch failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
18.7 KB

rerole

cburschka’s picture

Status: Needs review » Needs work

Changed files:

misc/form.js
modules/filter/filter.module
modules/statistics/statistics.admin.inc
modules/statistics/statistics.module
modules/statistics/statistics.test

I'm sure you didn't mean to eat a kitten. :P

dawehner’s picture

Status: Needs work » Needs review
FileSize
999 bytes

uh

thats strange :)

Status: Needs review » Needs work

The last submitted patch failed testing.

gpk’s picture

The cache_lifetime variable is widely misunderstood. Possibly including by me. I think of it as the delay until temporary/expired entries will actually be removed from the cache, once a cache wipe of such entries has been requested. AFAIK it was not intented to be used as suggested here.

NancyDru’s picture

Well, this one use is inconsistent with others, so maybe the core developers misunderstand it too?

gpk’s picture

Quite possibly :P (http://drupal.org/node/227228#comment-1501876).

In that related issue #227228: cache_clear_all and cache_get fail to clear caches when Minimum cache lifetime is on I suggested renaming it to cache_flush_delay: http://drupal.org/node/227228#comment-1278550. Never got round to it at the time; maybe it is time to do that now!

gpk’s picture

catch’s picture

Version: 7.x-dev » 8.x-dev
Category: bug » task
Status: Needs work » Active
Issue tags: +Performance

This should never be set to the value of cache_lifetime.

However it's also a bit senseless to hard code this to one day. I would make it a variable (with no user interface for it), defaulting to around 2-3 weeks so that entries that are never going to be used can be expired from the database cache, but we're not recreating the same caches over and over again on sites with a lot of content.

sun’s picture

Title: Check_markup hardcodes cache expiration » check_markup() hardcodes cache expiration
Status: Active » Needs review
Issue tags: +Needs backport to D7
FileSize
763 bytes

Meanwhile, I think this is fundamentally flawed.

A minimum cache expiration time does not really make any sense at all. The filtered text either changes or it does not. If it doesn't then there's no reason for flushing the cache.

The filtered text can only change when

  1. the input changes - which means that the cache hash automatically changes, too; the original cache "expires" automatically, it's just simply obsolete.
  2. the filter configuration for the text format is changed
catch’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs backport to D6

I was thinking we might want some garbage collection here, but that should be handled by full cache clears, or using a cache backend like memcache that does LRU. It's not much different to any other cache in Drupal on that front and you'd need a lot of content to run into issues - by that time you'll be running into the same issue elsewhere.

Filters can declare themselves uncacheable, so that is already handled (and 24 hours is arbitrary anyway).

RTBC.

xjm’s picture

Tagging issues not yet using summary template.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Good catch, and might actually yield a small performance improvement.

Committed to 7.x and 8.x.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

crea’s picture

The performance improvement here is not "small". Majority of search engine traffic is from low frequency keywords hitting rarely accessed pages. So for most of these visits the filter cache is missing and visitor experiences slow page generation time.
The patch from sun makes total sense and the pre-patch behavior was simply dumb.

catch’s picture

Version: 8.x-dev » 6.x-dev
Status: Closed (fixed) » Needs review
FileSize
626 bytes

This was never backported to D6. Was looking at performance issues on a site being very, very heavily crawled, and rebuilding the filter cache was taking a lot of time in a lot of pages.

sun’s picture

We should take over and backport the inline comment from #31, too.

The @see can be replaced with filter_admin_format_form_submit()

With that, the backport totally is RTBC (I just double-checked a couple of cache and filter functions for their D6 behavior).

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.