*** ../TWiki20040901/lib/TWiki.pm 2004-08-30 08:46:11.000000000 +0200
--- lib/TWiki.pm 2005-08-19 19:30:07.000000000 +0200
***************
*** 77,83 ****
$doLogTopicChanges $doLogTopicSearch $doLogRegistration
$superAdminGroup $doSuperAdminGroup $OS
$disableAllPlugins $attachAsciiPath $displayTimeValues
! $dispScriptUrlPath $dispViewPath
);
# Internationalisation (I18N) config from TWiki.cfg:
--- 77,83 ----
$doLogTopicChanges $doLogTopicSearch $doLogRegistration
$superAdminGroup $doSuperAdminGroup $OS
$disableAllPlugins $attachAsciiPath $displayTimeValues
! $dispScriptUrlPath $dispViewPath $expirationLastDateOffset
);
# Internationalisation (I18N) config from TWiki.cfg:
***************
*** 781,800 ****
sub writeHeader
{
! my( $query ) = @_;
# FIXME: Pass real content-length to make persistent connections work
# in HTTP/1.1 (performance improvement for browsers and servers).
# Requires significant but easy changes in various places.
# Just write a basic content-type header for text/html
! writeHeaderFull( $query, 'basic', 'text/html', 0);
}
=pod
! ---++ writeHeaderFull( $query, $pageType, $contentType, $contentLength )
Builds and outputs HTTP headers. $pageType should (currently) be either
"edit" or "basic". $query is the object from the CGI module, not the actual
--- 781,800 ----
sub writeHeader
{
! my( $query, $lastModifiedDate) = @_;
# FIXME: Pass real content-length to make persistent connections work
# in HTTP/1.1 (performance improvement for browsers and servers).
# Requires significant but easy changes in various places.
# Just write a basic content-type header for text/html
! writeHeaderFull( $query, 'basic', 'text/html', 0, $lastModifiedDate);
}
=pod
! ---++ writeHeaderFull( $query, $pageType, $contentType, $contentLength, $expireDate)
Builds and outputs HTTP headers. $pageType should (currently) be either
"edit" or "basic". $query is the object from the CGI module, not the actual
***************
*** 817,823 ****
sub writeHeaderFull
{
! my( $query, $pageType, $contentType, $contentLength ) = @_;
# Handle Edit pages - future versions will extend to caching
# of other types of page, with expiry time driven by page type.
--- 817,823 ----
sub writeHeaderFull
{
! my( $query, $pageType, $contentType, $contentLength, $lastModifiedDate) = @_;
# Handle Edit pages - future versions will extend to caching
# of other types of page, with expiry time driven by page type.
***************
*** 850,858 ****
-cache_control => "max-age=$expireSeconds",
);
} elsif ($pageType eq 'basic') {
$coreHeaders = $query->header(
! -content_type => $contentType,
);
} else {
writeWarning( "===== invalid page type in TWiki.pm, writeHeaderFull(): $pageType" );
}
--- 850,877 ----
-cache_control => "max-age=$expireSeconds",
);
} elsif ($pageType eq 'basic') {
+ if ($lastModifiedDate) {
+ my $lastModifiedDateString = &formatTime($lastModifiedDate, '\$http');
+ if ($expirationLastDateOffset) {
+ my $expirationDateString = &formatTime($lastModifiedDate +
+ $expirationLastDateOffset,
+ '\$http');
+ $coreHeaders = $query->header(
+ -content_type => $contentType,
+ -last_modified => $lastModifiedDateString,
+ -expires => $expirationDateString,
+ );
+ } else {
+ $coreHeaders = $query->header(
+ -content_type => $contentType,
+ -last_modified => $lastModifiedDateString,
+ );
+ }
+ } else {
$coreHeaders = $query->header(
! -content_type => $contentType,
);
+ }
} else {
writeWarning( "===== invalid page type in TWiki.pm, writeHeaderFull(): $pageType" );
}
***************
*** 2096,2101 ****
--- 2115,2127 ----
} # else is a file with relative path, e.g. $dataDir/../../path/to/non-twiki/file.ext
+ # sets correct last-modified-date
+ my ($revdate) = &TWiki::Store::getRevisionInfoFromMeta( $theWeb, $theTopic, $meta);
+ if ($revdate && (!$TWiki::UI::View::lastModifiedDate ||
+ ($TWiki::UI::View::lastModifiedDate < $revdate))) {
+ $TWiki::UI::View::lastModifiedDate = $revdate;
+ }
+
$text = applyPatternToIncludedText( $text, $pattern ) if( $pattern );
# handle all preferences and internal tags (for speed: call by reference)
*** ../TWiki20040901/lib/TWiki/UI/View.pm 2004-08-25 08:36:15.000000000 +0200
--- lib/TWiki/UI/View.pm 2005-08-19 19:30:07.000000000 +0200
***************
*** 44,49 ****
--- 44,51 ----
=cut
+ $TWiki::UI::View::lastModifiedDate = '';
+
sub view {
my ( $webName, $topic, $userName, $query ) = @_;
***************
*** 62,67 ****
--- 64,70 ----
my $extra = "";
my $wikiUserName = &TWiki::userToWikiName( $userName );
my $revdate = "";
+ my $revdatenum = "";
my $revuser = "";
$skin = &TWiki::Prefs::getPreferencesValue( "SKIN" ) unless ( $skin );
***************
*** 102,109 ****
} else {
( $meta, $text ) = &TWiki::Store::readTopic( $webName, $topic );
}
! ( $revdate, $revuser, $maxrev ) = &TWiki::Store::getRevisionInfoFromMeta( $webName, $topic, $meta);
! $revdate = TWiki::formatTime( $revdate );
if( $rev ) {
$rev =~ s/r?1\.//go; # cut 'r' and major
--- 105,112 ----
} else {
( $meta, $text ) = &TWiki::Store::readTopic( $webName, $topic );
}
! ( $revdatenum, $revuser, $maxrev ) = &TWiki::Store::getRevisionInfoFromMeta( $webName, $topic, $meta);
! $revdate = TWiki::formatTime( $revdatenum );
if( $rev ) {
$rev =~ s/r?1\.//go; # cut 'r' and major
***************
*** 119,126 ****
} else {
( $meta, $text ) = &TWiki::Store::readTopicVersion( $webName, $topic, "1.$rev" );
}
! ( $revdate, $revuser ) = &TWiki::Store::getRevisionInfo( $webName, $topic, "1.$rev");
! $revdate = TWiki::formatTime( $revdate );
$extra .= "r1.$rev";
}
} else {
--- 122,129 ----
} else {
( $meta, $text ) = &TWiki::Store::readTopicVersion( $webName, $topic, "1.$rev" );
}
! ( $revdatenum, $revuser ) = &TWiki::Store::getRevisionInfo( $webName, $topic, "1.$rev");
! $revdate = TWiki::formatTime( $revdatenum );
$extra .= "r1.$rev";
}
} else {
***************
*** 132,137 ****
--- 135,141 ----
}
$extra .= " (not exist)";
}
+ $TWiki::UI::View::lastModifiedDate = $revdatenum;
if( $viewRaw ) {
$extra .= " raw=$viewRaw";
***************
*** 293,300 ****
# Write header based on "contenttype" parameter, used to produce
# MIME types like text/plain or text/xml, e.g. for RSS feeds.
if( $contentType ) {
! TWiki::writeHeaderFull( $query, 'basic', $contentType, 0);
if( $skin =~ /^rss/ ) {
$tmpl =~ s/
]*>//g; # remove image tags
$tmpl =~ s/]*>//g; # remove anchor tags
--- 297,307 ----
# Write header based on "contenttype" parameter, used to produce
# MIME types like text/plain or text/xml, e.g. for RSS feeds.
+ if (!$TWiki::UI::View::lastModifiedDate) {
+ $TWiki::UI::View::lastModifiedDate = time();
+ }
if( $contentType ) {
! TWiki::writeHeaderFull( $query, 'basic', $contentType, 0, $TWiki::UI::View::lastModifiedDate);
if( $skin =~ /^rss/ ) {
$tmpl =~ s/
]*>//g; # remove image tags
$tmpl =~ s/]*>//g; # remove anchor tags
***************
*** 306,312 ****
$tmpl =~ s/]*>//g; # remove anchor tags
$tmpl =~ s/<\/a>//g; # remove anchor tags
} else {
! TWiki::writeHeader( $query );
}
# print page content
--- 313,319 ----
$tmpl =~ s/]*>//g; # remove anchor tags
$tmpl =~ s/<\/a>//g; # remove anchor tags
} else {
! TWiki::writeHeader( $query, $TWiki::UI::View::lastModifiedDate);
}
# print page content
*** ../TWiki20040901/lib/TWiki/Search.pm 2004-07-30 20:29:16.000000000 +0200
--- lib/TWiki/Search.pm 2005-08-19 19:30:07.000000000 +0200
***************
*** 385,390 ****
--- 385,393 ----
my @webList = ();
+ # set last-modified date in http headers to now
+ $TWiki::UI::View::lastModifiedDate = '';
+
# A value of 'all' or 'on' by itself gets all webs,
# otherwise ignored (unless there is a web called "All".)
my $searchAllFlag = ( $theWebName =~ /(^|[\,\s])(all|on)([\,\s]|$)/i );
*** ../TWiki20040901/lib/TWiki.cfg 2004-08-31 18:35:19.000000000 +0200
--- lib/TWiki.cfg 2005-08-19 19:29:57.000000000 +0200
***************
*** 443,448 ****
--- 443,451 ----
# Enable super-powers to $superAdminGroup members
# see Codev.UnchangeableTopicBug
$doSuperAdminGroup = "1";
+ #
+ # HTTP Header expire date as offset in seconds from last save
+ $expirationLastDateOffset = 60;
# Return true
1;