summaryrefslogtreecommitdiff
path: root/framework/Web/UI
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/UI')
-rw-r--r--framework/Web/UI/WebControls/TOutputCache.php23
1 files changed, 22 insertions, 1 deletions
diff --git a/framework/Web/UI/WebControls/TOutputCache.php b/framework/Web/UI/WebControls/TOutputCache.php
index 5e97a5d9..cb46b2f5 100644
--- a/framework/Web/UI/WebControls/TOutputCache.php
+++ b/framework/Web/UI/WebControls/TOutputCache.php
@@ -83,6 +83,7 @@ class TOutputCache extends TControl implements INamingContainer
private $_varyByParam='';
private $_keyPrefix='';
private $_varyBySession=false;
+ private $_cachePostBack=false;
/**
* Returns a value indicating whether body contents are allowed for this control.
@@ -101,7 +102,7 @@ class TOutputCache extends TControl implements INamingContainer
if(!$this->_cacheChecked)
{
$this->_cacheChecked=true;
- if(!$this->getPage()->getIsPostBack() && $this->_duration>0)
+ if($this->_duration>0 && ($this->_cachePostBack || !$this->getPage()->getIsPostBack()))
{
if($this->_cacheModuleID!=='')
{
@@ -405,6 +406,26 @@ class TOutputCache extends TControl implements INamingContainer
}
/**
+ * @return boolean whether cached output will be used on postback requests. Defaults to false.
+ */
+ public function getCachingPostBack()
+ {
+ return $this->_cachePostBack;
+ }
+
+ /**
+ * Sets a value indicating whether cached output will be used on postback requests.
+ * By default, this is disabled. Be very cautious when enabling it.
+ * If the cached content including interactive user controls such as
+ * TTextBox, TDropDownList, your page may fail to render on postbacks.
+ * @param boolean whether cached output will be used on postback requests.
+ */
+ public function setCachingPostBack($value)
+ {
+ $this->_cachePostBack=TPropertyValue::ensureBoolean($value);
+ }
+
+ /**
* This event is raised when the output cache is checking cache dependency.
* An event handler may be written to check customized dependency conditions.
* The checking result should be saved by setting {@link TOutputCacheCheckDependencyEventParameter::setIsValid IsValid}