Fix the issue with Assets with macro based content not showing the new content to Visitors. Fixes bug #11200.
This commit is contained in:
parent
21e1ac8da6
commit
e1c77cf314
7 changed files with 70 additions and 11 deletions
|
|
@ -112,7 +112,9 @@ sub handler {
|
|||
my $asset = getAsset($session, getRequestedAssetUrl($session));
|
||||
|
||||
# display from cache if page hasn't been modified.
|
||||
if ($var->get("userId") eq "1" && defined $asset && !$http->ifModifiedSince($asset->getContentLastModified)) {
|
||||
if ($var->get("userId") eq "1"
|
||||
&& defined $asset
|
||||
&& !$http->ifModifiedSince($asset->getContentLastModified, $session->setting->get('maxCacheTimeout'))) {
|
||||
$http->setStatus("304","Content Not Modified");
|
||||
$http->sendHeader;
|
||||
$session->close;
|
||||
|
|
|
|||
|
|
@ -204,6 +204,14 @@ sub definition {
|
|||
hoverHelp=>$i18n->get("Enable Metadata description"),
|
||||
defaultValue=>$setting->get("metaDataEnabled")
|
||||
});
|
||||
push(@fields, {
|
||||
tab=>"content",
|
||||
fieldType=>"interval",
|
||||
name=>"maxCacheTimeout",
|
||||
label=>$i18n->get("Maximum cache timeout"),
|
||||
hoverHelp=>$i18n->get("Maximum cache timeout description"),
|
||||
defaultValue=>$setting->get("maxCacheTimeout")
|
||||
});
|
||||
# user interface settings
|
||||
push(@fields, {
|
||||
tab=>"ui",
|
||||
|
|
|
|||
|
|
@ -205,19 +205,36 @@ sub getStreamedFile {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 ifModifiedSince ( epoch )
|
||||
=head2 ifModifiedSince ( epoch [, maxCacheTimeout] )
|
||||
|
||||
Returns 1 if the epoch is greater than the modified date check.
|
||||
|
||||
=head3 epoch
|
||||
|
||||
The date that the requested content was last modified in epoch format.
|
||||
|
||||
=head3 maxCacheTimeout
|
||||
|
||||
A modifier to the epoch, that allows us to set a maximum timeout where content will appear to
|
||||
have changed and a new page request will be allowed to be processed.
|
||||
|
||||
=cut
|
||||
|
||||
sub ifModifiedSince {
|
||||
my $self = shift;
|
||||
my $epoch = shift;
|
||||
my $self = shift;
|
||||
my $epoch = shift;
|
||||
my $maxCacheTimeout = shift;
|
||||
require APR::Date;
|
||||
my $modified = $self->session->request->headers_in->{'If-Modified-Since'};
|
||||
return 1 if ($modified eq "");
|
||||
$modified = APR::Date::parse_http($modified);
|
||||
##Implement a step function that increments the epoch time in integer multiples of
|
||||
##the maximum cache time. Used to handle the case where layouts containing macros
|
||||
##(like assetproxied Navigations) can be periodically updated.
|
||||
if ($maxCacheTimeout) {
|
||||
my $delta = time() - $epoch;
|
||||
$epoch += $delta - ($delta % $maxCacheTimeout);
|
||||
}
|
||||
return ($epoch > $modified);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4660,6 +4660,16 @@ Users may override this setting in their profile.
|
|||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'Maximum cache timeout' => {
|
||||
message => 'Maximum cache timeout',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'Maximum cache timeout description' => {
|
||||
message => 'This timeout will override the content check that is done before generating a page. It can help with caching problems for macros and Navigations. Setting it to 0 will disable the timeout. A setting of several hours is recommended.',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue