Commit 391068b6 by Scott

Option to prevent caching new questions

parent fbb97ca1
......@@ -732,7 +732,7 @@
* Generate array of split HTML (prefix, data, suffix) to represent a timestamp, optionally with the full date.
*
* @param int $timestamp Unix timestamp.
* @param bool $fulldatedays Number of days after which to show the full date.
* @param int $fulldatedays Number of days after which to show the full date.
* @return array The HTML.
*/
function qa_when_to_html($timestamp, $fulldatedays)
......
......@@ -215,7 +215,8 @@
'avatar_users_size' => 30,
'caching_catwidget_time' => 30,
'caching_enabled' => 0,
'caching_q_time' => 5,
'caching_q_start' => 7,
'caching_q_time' => 30,
'caching_qlist_time' => 5,
'captcha_on_anon_post' => 1,
'captcha_on_feedback' => 1,
......
......@@ -47,6 +47,7 @@
'block_ips_write' => 'Blocked IP addresses - separate by spaces or commas:',
'caching_catwidget_time' => 'Cache category widget for:',
'caching_enabled' => 'Enable caching:',
'caching_q_start' => 'Start caching questions after:',
'caching_q_time' => 'Cache question pages for:',
'caching_qlist_time' => 'Cache question lists for:',
'captcha_module' => 'Use captcha module:',
......
......@@ -74,6 +74,7 @@
'avatar_store_size' => 'number',
'avatar_users_size' => 'number',
'caching_catwidget_time' => 'number',
'caching_q_start' => 'number',
'caching_q_time' => 'number',
'caching_qlist_time' => 'number',
'columns_tags' => 'number',
......@@ -646,13 +647,7 @@
$subtitle = 'admin/caching_title';
$formstyle = 'wide';
$showoptions = array('caching_enabled', 'caching_q_time', 'caching_qlist_time', 'caching_catwidget_time');
$checkboxtodisplay = array(
'caching_q_time' => 'option_caching_enabled',
'caching_qlist_time' => 'option_caching_enabled',
'caching_catwidget_time' => 'option_caching_enabled',
);
$showoptions = array('caching_enabled', 'caching_q_start', 'caching_q_time', 'caching_qlist_time', 'caching_catwidget_time');
break;
......@@ -1555,7 +1550,10 @@
case 'caching_qlist_time':
case 'caching_catwidget_time':
$optionfield['note'] = qa_lang_html_sub('main/x_minutes', '');
break;
break;
case 'caching_q_start':
$optionfield['note'] = qa_lang_html_sub('main/x_days', '');
break;
}
if (isset($feedrequest) && $value)
......@@ -1786,7 +1784,6 @@
case 'caching':
$cacheManager = Q2A_Storage_CacheManager::getInstance();
$qa_content['error'] = $cacheManager->getError();
break;
}
......
......@@ -153,10 +153,13 @@
}
// Save question data to cache
// Save question data to cache (if older than configured limit)
if ($saveCache) {
$cacheHandler->set($cacheKey, $questionData, qa_opt('caching_q_time'));
$questionAge = qa_opt('db_time') - $question['created'];
if ($questionAge > 86400 * qa_opt('caching_q_start')) {
$cacheHandler->set($cacheKey, $questionData, qa_opt('caching_q_time'));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment