From e4392f7449c417f97303701394e8467ea4066ce4 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Wed, 5 Apr 2006 20:46:57 +0000 Subject: [PATCH] new caching system to replace old page cache --- docs/changelog/6.x.x.txt | 2 + docs/migration.txt | 11 ++++ docs/upgrades/upgrade_6.8.7-6.99.0.pl | 20 +++++++ lib/WebGUI/Asset/Event.pm | 26 ++++++++- lib/WebGUI/Asset/File.pm | 33 ++++++++++- lib/WebGUI/Asset/File/Image.pm | 10 +++- lib/WebGUI/Asset/File/ZipArchive.pm | 10 +++- lib/WebGUI/Asset/Post.pm | 14 +++++ lib/WebGUI/Asset/Post/Thread.pm | 26 ++++++++- lib/WebGUI/Asset/Wobject.pm | 16 ------ lib/WebGUI/Asset/Wobject/Article.pm | 33 ++++++++++- lib/WebGUI/Asset/Wobject/Collaboration.pm | 41 +++++++++++++- lib/WebGUI/Asset/Wobject/DataForm.pm | 12 ---- lib/WebGUI/Asset/Wobject/EventsCalendar.pm | 55 ++++++++++++++----- lib/WebGUI/Asset/Wobject/Folder.pm | 49 ++++++++++++++--- lib/WebGUI/Asset/Wobject/HttpProxy.pm | 39 ++++++++++--- lib/WebGUI/Asset/Wobject/InOutBoard.pm | 4 -- lib/WebGUI/Asset/Wobject/Matrix.pm | 41 +++++++++++++- lib/WebGUI/Asset/Wobject/MessageBoard.pm | 41 +++++++++++++- lib/WebGUI/Asset/Wobject/MultiSearch.pm | 33 ++++++++++- lib/WebGUI/Asset/Wobject/Product.pm | 33 ++++++++++- lib/WebGUI/Asset/Wobject/SQLReport.pm | 36 +++++++++++- lib/WebGUI/Asset/Wobject/StockData.pm | 11 ---- lib/WebGUI/Asset/Wobject/Survey.pm | 12 ---- lib/WebGUI/Asset/Wobject/SyndicatedContent.pm | 34 +++++++++++- lib/WebGUI/Asset/Wobject/_NewWobject.skeleton | 15 ----- lib/WebGUI/AssetBranch.pm | 18 ------ lib/WebGUI/AssetExportHtml.pm | 1 - lib/WebGUI/Help/Asset_Article.pm | 5 ++ lib/WebGUI/Help/Asset_Collaboration.pm | 5 ++ lib/WebGUI/Help/Asset_EventsCalendar.pm | 5 ++ lib/WebGUI/Help/Asset_File.pm | 5 ++ lib/WebGUI/Help/Asset_Folder.pm | 5 ++ lib/WebGUI/Help/Asset_HttpProxy.pm | 5 ++ lib/WebGUI/Help/Asset_Matrix.pm | 5 ++ lib/WebGUI/Help/Asset_MessageBoard.pm | 5 ++ lib/WebGUI/Help/Asset_MultiSearch.pm | 5 ++ lib/WebGUI/Help/Asset_Product.pm | 5 ++ lib/WebGUI/Help/Asset_SQLReport.pm | 5 ++ lib/WebGUI/Help/Asset_SyndicatedContent.pm | 5 ++ lib/WebGUI/Help/Asset_Wobject.pm | 12 ---- lib/WebGUI/i18n/English/Asset_Article.pm | 10 ++++ .../i18n/English/Asset_Collaboration.pm | 10 ++++ .../i18n/English/Asset_EventsCalendar.pm | 10 ++++ lib/WebGUI/i18n/English/Asset_File.pm | 10 ++++ lib/WebGUI/i18n/English/Asset_Folder.pm | 10 ++++ lib/WebGUI/i18n/English/Asset_HttpProxy.pm | 10 ++++ lib/WebGUI/i18n/English/Asset_Matrix.pm | 10 ++++ lib/WebGUI/i18n/English/Asset_MessageBoard.pm | 10 ++++ lib/WebGUI/i18n/English/Asset_MultiSearch.pm | 10 ++++ lib/WebGUI/i18n/English/Asset_Product.pm | 10 ++++ lib/WebGUI/i18n/English/Asset_SQLReport.pm | 10 ++++ .../i18n/English/Asset_SyndicatedContent.pm | 10 ++++ lib/WebGUI/i18n/English/Asset_Wobject.pm | 17 ------ 54 files changed, 718 insertions(+), 167 deletions(-) diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index d26f54308..95f0ed633 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -26,6 +26,8 @@ - Added archive/unarchive options to CS threads. - Increased the performance of CS Thread viewing by 500%. - Added a database cache option as an alternative to memcached. + - Removed page caching system and added individual asset caches, because not + everything should cache in the same way. - Converted WebGUI to use a new object oriented session system. More details in migation.txt. - Added a lot more tests to the test suite. diff --git a/docs/migration.txt b/docs/migration.txt index 38c3d621b..8191226d8 100644 --- a/docs/migration.txt +++ b/docs/migration.txt @@ -206,6 +206,17 @@ prepareView() in which HTML and HTTP headers must be set. See any of the existing assets and wobjects for implementation details. +1.9 Removed Page Caching + +The page caching system that was cacheTimeout and cacheTimeoutVisitor on +wobjects has been removed. Not everything caches in the same way and therefore +we can't use a generic caching mechanism as much as we'd like to. Likewise, +the www_view(1) cache override that has traditionally been used in wobjects is +now gone since it's useless. If your asset needs caching, you'll need to add +it yourself. See one of the dozen or so assets that come with WebGUI for +ideas. Examples include Article, SQL Report, File, and Folder. + + 2. Macro Migration ------------------- diff --git a/docs/upgrades/upgrade_6.8.7-6.99.0.pl b/docs/upgrades/upgrade_6.8.7-6.99.0.pl index 3fc2fceca..1a3f27bf9 100644 --- a/docs/upgrades/upgrade_6.8.7-6.99.0.pl +++ b/docs/upgrades/upgrade_6.8.7-6.99.0.pl @@ -27,6 +27,7 @@ my $session = start(); # this line required addWorkflow(); convertMessageLogToInbox(); updateCs(); +changeCache(); templateParsers(); removeFiles(); addSearchEngine(); @@ -45,6 +46,25 @@ addAdManager(); finish($session); # this line required +#------------------------------------------------- +sub changeCache { + print "\tChanging page cache system.\n"; + $session->db->write("alter table MessageBoard add column visitorCacheTimeout int not null default 3600"); + $session->db->write("alter table Matrix add column visitorCacheTimeout int not null default 3600"); + $session->db->write("alter table Collaboration add column visitorCacheTimeout int not null default 3600"); + $session->db->write("alter table EventsCalendar add column visitorCacheTimeout int not null default 3600"); + $session->db->write("alter table Folder add column visitorCacheTimeout int not null default 3600"); + $session->db->write("alter table HttpProxy add column cacheTimeout int not null default 0"); + $session->db->write("alter table SQLReport add column cacheTimeout int not null default 0"); + $session->db->write("alter table FileAsset add column cacheTimeout int not null default 3600"); + $session->db->write("alter table Product add column cacheTimeout int not null default 3600"); + $session->db->write("alter table SyndicatedContent add column cacheTimeout int not null default 3600"); + $session->db->write("alter table MultiSearch add column cacheTimeout int not null default 3600"); + $session->db->write("alter table Article add column cacheTimeout int not null default 3600"); + $session->db->write("alter table wobject drop column cacheTimeout"); + $session->db->write("alter table wobject drop column cacheTimeoutVisitor"); +} + #------------------------------------------------- sub addAdManager { print "\tAdding advertising management.\n"; diff --git a/lib/WebGUI/Asset/Event.pm b/lib/WebGUI/Asset/Event.pm index b5eb25ff0..4992c8fff 100644 --- a/lib/WebGUI/Asset/Event.pm +++ b/lib/WebGUI/Asset/Event.pm @@ -13,6 +13,7 @@ package WebGUI::Asset::Event; use strict; use Tie::CPHash; use WebGUI::Form; +use WebGUI::Cache; use WebGUI::HTML; use WebGUI::HTMLForm; use WebGUI::International; @@ -192,6 +193,21 @@ sub processPropertiesFromFormPost { } +#------------------------------------------------------------------- + +=head2 purgeCache () + +See WebGUI::Asset::purgeCache() for details. + +=cut + +sub purgeCache { + my $self = shift; + WebGUI::Cache->new($self->session,"view_".$self->getId)->delete; + $self->SUPER::purgeCache; + $self->getParent->purgeCache; +} + #------------------------------------------------------------------- =head2 setParent ( newParent ) @@ -214,6 +230,10 @@ sub setParent { #------------------------------------------------------------------- sub view { my $self = shift; + if ($self->session->user->userId eq '1') { + my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; + return $out if $out; + } my ($output, $event, $id); my %var = $self->get; my $i18n = WebGUI::International->new($self->session,"Asset_Event"); @@ -245,7 +265,11 @@ sub view { }); } $var{others_loop} = \@others; - return $self->processTemplate(\%var,undef, $self->{_viewTemplate}); + my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate}); + if ($self->session->user->userId eq '1') { + WebGUI::Cache->new($self->session,"view_".$self->getId)->set($out,$self->getParent->get("visitorCacheTimeout")); + } + return $out; } diff --git a/lib/WebGUI/Asset/File.pm b/lib/WebGUI/Asset/File.pm index 995869c17..b97b52c01 100644 --- a/lib/WebGUI/Asset/File.pm +++ b/lib/WebGUI/Asset/File.pm @@ -16,6 +16,7 @@ package WebGUI::Asset::File; use strict; use WebGUI::Asset; +use WebGUI::Cache; use WebGUI::Storage; use WebGUI::SQL; @@ -83,6 +84,14 @@ sub definition { tableName=>'FileAsset', className=>'WebGUI::Asset::File', properties=>{ + cacheTimeout => { + tab => "display", + fieldType => "interval", + defaultValue => 3600, + uiLevel => 8, + label => $i18n->get("cache timeout"), + hoverHelp => $i18n->get("cache timeout help") + }, filename=>{ noFormPost=>1, fieldType=>'hidden', @@ -250,6 +259,20 @@ sub purge { #------------------------------------------------------------------- +=head2 purgeCache () + +See WebGUI::Asset::purgeCache() for details. + +=cut + +sub purgeCache { + my $self = shift; + WebGUI::Cache->new($self->session,"view_".$self->getId)->delete; + $self->SUPER::purgeCache; +} + +#------------------------------------------------------------------- + sub purgeRevision { my $self = shift; $self->getStorageLocation->delete; @@ -291,11 +314,19 @@ sub update { #------------------------------------------------------------------- sub view { my $self = shift; + if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { + my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; + return $out if $out; + } my %var = %{$self->get}; $var{controls} = $self->getToolbar; $var{fileUrl} = $self->getFileUrl; $var{fileIcon} = $self->getFileIconUrl; - return $self->processTemplate(\%var, undef, $self->{_viewTemplate}); + my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate}); + if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { + WebGUI::Cache->new($self->session,"view_".$self->getId)->set($out,$self->get("cacheTimeout")); + } + return $out; } diff --git a/lib/WebGUI/Asset/File/Image.pm b/lib/WebGUI/Asset/File/Image.pm index 600672835..92dd646fd 100644 --- a/lib/WebGUI/Asset/File/Image.pm +++ b/lib/WebGUI/Asset/File/Image.pm @@ -232,12 +232,20 @@ sub setSize { #------------------------------------------------------------------- sub view { my $self = shift; + if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { + my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; + return $out if $out; + } my %var = %{$self->get}; $var{controls} = $self->getToolbar; $var{fileUrl} = $self->getFileUrl; $var{fileIcon} = $self->getFileIconUrl; $var{thumbnail} = $self->getThumbnailUrl; - return $self->processTemplate(\%var,undef,$self->{_viewTemplate}); + my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate}); + if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { + WebGUI::Cache->new($self->session,"view_".$self->getId)->set($out,$self->get("cacheTimeout")); + } + return $out; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Asset/File/ZipArchive.pm b/lib/WebGUI/Asset/File/ZipArchive.pm index 8b3f16645..2972f4126 100644 --- a/lib/WebGUI/Asset/File/ZipArchive.pm +++ b/lib/WebGUI/Asset/File/ZipArchive.pm @@ -251,6 +251,10 @@ used to show the file to administrators. sub view { my $self = shift; + if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { + my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; + return $out if $out; + } my %var = %{$self->get}; #$self->session->errorHandler->warn($self->getId); $var{controls} = $self->getToolbar; @@ -266,7 +270,11 @@ sub view { unless($self->get("showPage")) { $var{pageError} = "true"; } - return $self->processTemplate(\%var,undef,$self->{_viewTemplate}); + my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate}); + if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { + WebGUI::Cache->new($self->session,"view_".$self->getId)->set($out,$self->get("cacheTimeout")); + } + return $out; } diff --git a/lib/WebGUI/Asset/Post.pm b/lib/WebGUI/Asset/Post.pm index f9ac4729d..33487dbc2 100644 --- a/lib/WebGUI/Asset/Post.pm +++ b/lib/WebGUI/Asset/Post.pm @@ -696,6 +696,20 @@ sub purge { #------------------------------------------------------------------- +=head2 purgeCache () + +See WebGUI::Asset::purgeCache() for details. + +=cut + +sub purgeCache { + my $self = shift; + $self->getThread->purgeCache if $self->isReply; + $self->SUPER::purgeCache; +} + +#------------------------------------------------------------------- + sub purgeRevision { my $self = shift; $self->getStorageLocation->delete; diff --git a/lib/WebGUI/Asset/Post/Thread.pm b/lib/WebGUI/Asset/Post/Thread.pm index 4aa72fef7..c67559e55 100644 --- a/lib/WebGUI/Asset/Post/Thread.pm +++ b/lib/WebGUI/Asset/Post/Thread.pm @@ -13,6 +13,7 @@ package WebGUI::Asset::Post::Thread; use strict; use WebGUI::Asset::Template; use WebGUI::Asset::Post; +use WebGUI::Cache; use WebGUI::Group; use WebGUI::International; use WebGUI::Paginator; @@ -534,6 +535,21 @@ sub purge { #------------------------------------------------------------------- +=head2 purgeCache () + +See WebGUI::Asset::purgeCache() for details. + +=cut + +sub purgeCache { + my $self = shift; + WebGUI::Cache->new($self->session,"view_".$self->getId)->delete; + $self->SUPER::purgeCache; + $self->getParent->purgeCache; +} + +#------------------------------------------------------------------- + =head2 rate ( rating ) Stores a rating against this post. @@ -736,6 +752,10 @@ sub view { my $self = shift; $self->markRead; $self->incrementViews unless ($self->session->form->process("func") eq 'rate'); + if ($self->session->user->userId eq '1' && !$self->session->form->process("layout")) { + my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; + return $out if $out; + } $self->session->scratch->set("discussionLayout",$self->session->form->process("layout")); my $var = $self->getTemplateVars; $self->getParent->appendTemplateLabels($var); @@ -827,7 +847,11 @@ sub view { $var->{"collaboration.url"} = $self->getThread->getParent->getUrl; $var->{'collaboration.title'} = $self->getParent->get("title"); $var->{'collaboration.description'} = $self->getParent->get("description"); - return $self->processTemplate($var,undef,$self->{_viewTemplate}); + my $out = $self->processTemplate($var,undef,$self->{_viewTemplate}); + if ($self->session->user->userId eq '1' && !$self->session->form->process("layout")) { + WebGUI::Cache->new($self->session,"view_".$self->getId)->set($out,$self->getThread->getParent->get("visitorCacheTimeout")); + } + return $out; } diff --git a/lib/WebGUI/Asset/Wobject.pm b/lib/WebGUI/Asset/Wobject.pm index 10afdb93f..912ba1ae9 100644 --- a/lib/WebGUI/Asset/Wobject.pm +++ b/lib/WebGUI/Asset/Wobject.pm @@ -82,22 +82,6 @@ sub definition { hoverHelp=>$i18n->get('174 description'), uiLevel=>5 }, - cacheTimeout=>{ - fieldType=>'interval', - defaultValue=>60, - tab=>"display", - label=>$i18n->get(895), - hoverHelp=>$i18n->get('895 description'), - uiLevel=>8 - }, - cacheTimeoutVisitor=>{ - fieldType=>'interval', - defaultValue=>600, - tab=>"display", - label=>$i18n->get(896), - hoverHelp=>$i18n->get('896 description'), - uiLevel=>8 - }, styleTemplateId=>{ fieldType=>'template', defaultValue=>undef, diff --git a/lib/WebGUI/Asset/Wobject/Article.pm b/lib/WebGUI/Asset/Wobject/Article.pm index 64fbbd6be..44e5b3ee4 100644 --- a/lib/WebGUI/Asset/Wobject/Article.pm +++ b/lib/WebGUI/Asset/Wobject/Article.pm @@ -13,6 +13,7 @@ package WebGUI::Asset::Wobject::Article; use strict; use Tie::IxHash; use WebGUI::International; +use WebGUI::Cache; use WebGUI::Paginator; use WebGUI::Asset::Wobject; @@ -73,6 +74,14 @@ sub definition { my %properties; tie %properties, 'Tie::IxHash'; %properties = ( + cacheTimeout => { + tab => "display", + fieldType => "interval", + defaultValue => 3600, + uiLevel => 8, + label => $i18n->get("cache timeout"), + hoverHelp => $i18n->get("cache timeout help") + }, templateId =>{ fieldType=>"template", defaultValue=>'PBtmpl0000000000000002', @@ -139,6 +148,20 @@ sub prepareView { } +#------------------------------------------------------------------- + +=head2 purgeCache () + +See WebGUI::Asset::purgeCache() for details. + +=cut + +sub purgeCache { + my $self = shift; + WebGUI::Cache->new($self->session,"view_".$self->getId)->delete; + $self->SUPER::purgeCache; +} + #------------------------------------------------------------------- =head2 view ( ) @@ -150,6 +173,10 @@ returns the output. sub view { my $self = shift; + if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10 && !$self->session->form->process("overrideTemplateId") && !$self->session->form->process("pn") && !$self->session->form->process("makePrintable")) { + my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; + return $out if $out; + } my %var; my $children = $self->getLineage(["children"],{returnObjects=>1,includeOnlyClasses=>["WebGUI::Asset::File","WebGUI::Asset::File::Image"]}); foreach my $child (@{$children}) { @@ -201,7 +228,11 @@ sub view { $var{description} = $p->getPage; } $p->appendTemplateVars(\%var); - return $self->processTemplate(\%var, undef, $self->{_viewTemplate}); + my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate}); + if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10 && !$self->session->form->process("overrideTemplateId") && !$self->session->form->process("pn") && !$self->session->form->process("makePrintable")) { + WebGUI::Cache->new($self->session,"view_".$self->getId)->set($out,$self->get("cacheTimeout")); + } + return $out; } 1; diff --git a/lib/WebGUI/Asset/Wobject/Collaboration.pm b/lib/WebGUI/Asset/Wobject/Collaboration.pm index 06f63b656..2b1ac6f57 100644 --- a/lib/WebGUI/Asset/Wobject/Collaboration.pm +++ b/lib/WebGUI/Asset/Wobject/Collaboration.pm @@ -13,6 +13,7 @@ package WebGUI::Asset::Wobject::Collaboration; use strict; use Tie::IxHash; use WebGUI::Group; +use WebGUI::Cache; use WebGUI::HTML; use WebGUI::International; use WebGUI::Paginator; @@ -248,6 +249,14 @@ sub definition { tableName=>'Collaboration', className=>'WebGUI::Asset::Wobject::Collaboration', properties=>{ + visitorCacheTimeout => { + tab => "display", + fieldType => "interval", + defaultValue => 3600, + uiLevel => 8, + label => $i18n->get("visitor cache timeout"), + hoverHelp => $i18n->get("visitor cache timeout help") + }, approvalWorkflow =>{ fieldType=>"workflow", defaultValue=>"pbworkflow000000000003" @@ -410,6 +419,14 @@ sub getEditForm { my $self = shift; my $tabform = $self->SUPER::getEditForm; my $i18n = WebGUI::International->new($self->session,"Asset_Collaboration"); + $tabform->getTab("display")->interval( + -name=>"visitorCacheTimeout", + -label=>$i18n->get('visitor cache timeout'), + -hoverHelp=>$i18n->get('visitor cache timeout help'), + -value=>$self->getValue('visitorCacheTimeout'), + -uiLevel=>8, + -defaultValue=>3600 + ); $tabform->getTab("display")->yesNo( -value=>$self->getValue('displayLastReply'), -label=>$i18n->get('display last reply'), @@ -822,6 +839,20 @@ sub purge { #------------------------------------------------------------------- +=head2 purgeCache () + +See WebGUI::Asset::purgeCache() for details. + +=cut + +sub purgeCache { + my $self = shift; + WebGUI::Cache->new($self->session,"view_".$self->getId)->delete; + $self->SUPER::purgeCache; +} + +#------------------------------------------------------------------- + =head2 recalculateRating ( ) Calculates the rating of this forum from its threads and stores the new value in the forum properties. @@ -895,6 +926,10 @@ sub unsubscribe { #------------------------------------------------------------------- sub view { my $self = shift; + if ($self->session->user->userId eq '1' && !$self->session->form->process("sortBy")) { + my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; + return $out if $out; + } my $scratchSortBy = $self->getId."_sortBy"; my $scratchSortOrder = $self->getId."_sortDir"; my $sortBy = $self->session->form->process("sortBy") || $self->session->scratch->get($scratchSortBy) || $self->get("sortBy"); @@ -942,7 +977,11 @@ sub view { my $p = WebGUI::Paginator->new($self->session,$self->getUrl,$self->get("threadsPerPage")); $self->appendPostListTemplateVars(\%var, $sql, $p); $self->appendTemplateLabels(\%var); - return $self->processTemplate(\%var,undef, $self->{_viewTemplate}); + my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate}); + if ($self->session->user->userId eq '1' && !$self->session->form->process("sortBy")) { + WebGUI::Cache->new($self->session,"view_".$self->getId)->set($out,$self->get("visitorCacheTimeout")); + } + return $out; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Asset/Wobject/DataForm.pm b/lib/WebGUI/Asset/Wobject/DataForm.pm index 7a0b4488a..6db9d4345 100644 --- a/lib/WebGUI/Asset/Wobject/DataForm.pm +++ b/lib/WebGUI/Asset/Wobject/DataForm.pm @@ -1137,18 +1137,6 @@ sub www_process { } } -#------------------------------------------------------------------- -=head2 www_view ( ) - -Overwrite www_view method and call the superclass object, passing in a 1 to disable cache - -=cut - -sub www_view { - my $self = shift; - $self->SUPER::www_view(1); - -} 1; diff --git a/lib/WebGUI/Asset/Wobject/EventsCalendar.pm b/lib/WebGUI/Asset/Wobject/EventsCalendar.pm index 1ecae038a..0d291ccdd 100644 --- a/lib/WebGUI/Asset/Wobject/EventsCalendar.pm +++ b/lib/WebGUI/Asset/Wobject/EventsCalendar.pm @@ -12,6 +12,7 @@ package WebGUI::Asset::Wobject::EventsCalendar; use strict; use Tie::CPHash; +use WebGUI::Cache; use WebGUI::International; use WebGUI::SQL; use WebGUI::Utility; @@ -45,6 +46,14 @@ sub definition { tableName=>'EventsCalendar', className=>'WebGUI::Asset::Wobject::EventsCalendar', properties=>{ + visitorCacheTimeout => { + tab => "display", + fieldType => "interval", + defaultValue => 3600, + uiLevel => 8, + label => $i18n->get("visitor cache timeout"), + hoverHelp => $i18n->get("visitor cache timeout help") + }, templateId =>{ fieldType=>"template", defaultValue=>'PBtmpl0000000000000022' @@ -116,6 +125,14 @@ sub getEditForm { 2=>$i18n->get(509), } ); + $tabform->getTab("display")->interval( + -name=>"visitorCacheTimeout", + -label=>$i18n->get('visitor cache timeout'), + -hoverHelp=>$i18n->get('visitor cache timeout help'), + -value=>$self->getValue('visitorCacheTimeout'), + -uiLevel=>8, + -defaultValue=>3600 + ); $tabform->getTab("display")->template( -name=>"templateId", -label=>$i18n->get(94), @@ -198,9 +215,27 @@ sub prepareView { } +#------------------------------------------------------------------- + +=head2 purgeCache () + +See WebGUI::Asset::purgeCache() for details. + +=cut + +sub purgeCache { + my $self = shift; + WebGUI::Cache->new($self->session,"view_".$self->getId)->delete; + $self->SUPER::purgeCache; +} + #------------------------------------------------------------------- sub view { my $self = shift; + if ($self->session->user->userId eq '1' && !$self->session->form->process("calMonthStart") && !$self->session->form->process("calMonthEnd")) { + my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; + return $out if $out; + } my $i18n = WebGUI::International->new($self->session,"Asset_EventsCalendar"); #define default view month range. Note that this could be different from #the range a user is allowed to view - set by the events calendar limitations. @@ -466,25 +501,15 @@ sub view { '; - #use Data::Dumper; return '
'.Dumper(\%var).'
'; - my $vars = \%var; - return $self->processTemplate($vars,undef,$self->{_viewTemplate}); + my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate}); + if ($self->session->user->userId eq '1' && !$self->session->form->process("calMonthStart") && !$self->session->form->process("calMonthEnd")) { + WebGUI::Cache->new($self->session,"view_".$self->getId)->set($out,$self->get("visitorCacheTimeout")); + } + return $out; } -#------------------------------------------------------------------- -=head2 www_view ( ) - -Overwrite www_view method and call the superclass object, passing in a 1 to disable cache - -=cut - -sub www_view { - my $self = shift; - $self->SUPER::www_view(1); - -} 1; diff --git a/lib/WebGUI/Asset/Wobject/Folder.pm b/lib/WebGUI/Asset/Wobject/Folder.pm index 4ba42a53f..b968a1a76 100644 --- a/lib/WebGUI/Asset/Wobject/Folder.pm +++ b/lib/WebGUI/Asset/Wobject/Folder.pm @@ -16,6 +16,7 @@ package WebGUI::Asset::Wobject::Folder; use strict; use WebGUI::Asset::Wobject; +use WebGUI::Cache; use WebGUI::Utility; our @ISA = qw(WebGUI::Asset::Wobject); @@ -65,6 +66,14 @@ sub definition { tableName=>'Folder', className=>'WebGUI::Asset::Wobject::Folder', properties=>{ + visitorCacheTimeout => { + tab => "display", + fieldType => "interval", + defaultValue => 3600, + uiLevel => 8, + label => $i18n->get("visitor cache timeout"), + hoverHelp => $i18n->get("visitor cache timeout help") + }, templateId =>{ fieldType=>"template", defaultValue=>'PBtmpl0000000000000078' @@ -88,6 +97,14 @@ sub getEditForm { my $self = shift; my $tabform = $self->SUPER::getEditForm(); my $i18n = WebGUI::International->new($self->session,"Asset_Folder"); + $tabform->getTab("display")->interval( + -name=>"visitorCacheTimeout", + -label=>$i18n->get('visitor cache timeout'), + -hoverHelp=>$i18n->get('visitor cache timeout help'), + -value=>$self->getValue('visitorCacheTimeout'), + -uiLevel=>8, + -defaultValue=>3600 + ); $tabform->getTab("display")->template( -value=>$self->getValue('templateId'), -label=>$i18n->get('folder template title'), @@ -124,9 +141,27 @@ sub prepareView { } +#------------------------------------------------------------------- + +=head2 purgeCache () + +See WebGUI::Asset::purgeCache() for details. + +=cut + +sub purgeCache { + my $self = shift; + WebGUI::Cache->new($self->session,"view_".$self->getId)->delete; + $self->SUPER::purgeCache; +} + #------------------------------------------------------------------- sub view { my $self = shift; + if ($self->session->user->userId eq '1') { + my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; + return $out if $out; + } my $children = $self->getLineage( ["children"], { returnObjects=>1 }); my %vars; foreach my $child (@{$children}) { @@ -164,18 +199,14 @@ sub view { }); } } - return $self->processTemplate(\%vars,undef,$self->{_viewTemplate}); + my $out = $self->processTemplate(\%vars,undef,$self->{_viewTemplate}); + if ($self->session->user->userId eq '1') { + WebGUI::Cache->new($self->session,"view_".$self->getId)->set($out,$self->get("visitorCacheTimeout")); + } + return $out; } -#sub www_edit { -# my $self = shift; -# return $self->session->privilege->insufficient() unless $self->canEdit; -# $self->getAdminConsole->setHelp("folder add/edit","Asset_Folder"); -# return $self->getAdminConsole->render($self->getEditForm->print,"Edit Folder"); -#} - - 1; diff --git a/lib/WebGUI/Asset/Wobject/HttpProxy.pm b/lib/WebGUI/Asset/Wobject/HttpProxy.pm index b51eb291f..c2cea5584 100644 --- a/lib/WebGUI/Asset/Wobject/HttpProxy.pm +++ b/lib/WebGUI/Asset/Wobject/HttpProxy.pm @@ -54,6 +54,10 @@ sub definition { fieldType=>"yesNo", defaultValue=>1 }, + cacheTimeout=>{ + fieldType=>"interval", + defaultValue=>0 + }, filterHtml=>{ fieldType=>"filterContent", defaultValue=>"javascript" @@ -139,6 +143,13 @@ sub getEditForm { -hoverHelp=>$i18n->get('12 description'), -value=>$self->getValue("rewriteUrls") ); + $tabform->getTab("display")->interval( + -name=>"cacheTimeout", + -label=>$i18n->get('cache timeout'), + -hoverHelp=>$i18n->get('cache timeout description'), + -uiLevel => 8, + -value=>$self->getValue("cacheTimeout") + ); $tabform->getTab("display")->yesNo( -name=>"removeStyle", -label=>$i18n->get(6), @@ -197,6 +208,21 @@ sub purge { } +#------------------------------------------------------------------- + +=head2 purgeCache () + +See WebGUI::Asset::purgeCache() for details. + +=cut + +sub purgeCache { + my $self = shift; + WebGUI::Cache->new($self->session,$self->get("proxiedUrl"),"URL")->delete; + WebGUI::Cache->new($self->session,$self->get("proxiedUrl"),"HEADER")->delete; + $self->SUPER::purgeCache; +} + #------------------------------------------------------------------- sub view { my $self = shift; @@ -204,7 +230,7 @@ sub view { $cookiebox =~ s/[^A-Za-z0-9\-\.\_]//g; #removes all funky characters $cookiebox .= '.cookie'; my $jar = HTTP::Cookies->new(File => $self->getCookieJar->getPath($cookiebox), AutoSave => 1, Ignore_Discard => 1); - my (%var, %formdata, @formUpload, $redirect, $response, $header, $userAgent, $proxiedUrl, $request, $ttl); + my (%var, %formdata, @formUpload, $redirect, $response, $header, $userAgent, $proxiedUrl, $request); if($self->session->form->process("func")!~/editSave/i) { $proxiedUrl = $self->session->form->process("FormAction") || $self->session->form->process("proxiedUrl") || $self->get("proxiedUrl") ; @@ -338,14 +364,9 @@ sub view { $var{content} = "Getting $proxiedUrl failed". "

GET status line: ".$response->status_line.""; } - if ($self->session->user->userId eq '1') { - $ttl = $self->get("cacheTimeoutVisitor"); - } else { - $ttl = $self->get("cacheTimeout"); - } - unless ($self->get("cacheTimeoutVisitor") <= 1 && $self->get("cacheTimeout") <= 1) { - $cachedContent->set($var{content},$ttl); - $cachedHeader->set($var{header},$ttl); + unless ($self->get("cacheTimeout") <= 10) { + $cachedContent->set($var{content},$self->get("cacheTimeout")); + $cachedHeader->set($var{header},$self->get("cacheTimeout")); } } diff --git a/lib/WebGUI/Asset/Wobject/InOutBoard.pm b/lib/WebGUI/Asset/Wobject/InOutBoard.pm index bea6ff85e..01d4d51be 100644 --- a/lib/WebGUI/Asset/Wobject/InOutBoard.pm +++ b/lib/WebGUI/Asset/Wobject/InOutBoard.pm @@ -398,10 +398,6 @@ sub www_setStatus { return $self->www_view; } -sub www_view { - my $self = shift; - $self->SUPER::www_view(1); -} #------------------------------------------------------------------- sub www_viewReport { diff --git a/lib/WebGUI/Asset/Wobject/Matrix.pm b/lib/WebGUI/Asset/Wobject/Matrix.pm index 114b1c890..4289a51cc 100644 --- a/lib/WebGUI/Asset/Wobject/Matrix.pm +++ b/lib/WebGUI/Asset/Wobject/Matrix.pm @@ -4,6 +4,7 @@ use strict; use Tie::IxHash; use WebGUI::Form; use WebGUI::HTMLForm; +use WebGUI::Cache; use WebGUI::Mail::Send; use WebGUI::SQL; use WebGUI::User; @@ -27,6 +28,14 @@ sub definition { className=>'WebGUI::Asset::Wobject::Matrix', assetName=>$i18n->get('assetName'), properties=>{ + visitorCacheTimeout => { + tab => "display", + fieldType => "interval", + defaultValue => 3600, + uiLevel => 8, + label => $i18n->get("visitor cache timeout"), + hoverHelp => $i18n->get("visitor cache timeout help") + }, categories=>{ defaultValue=>"Features\nBenefits", fieldType=>"textarea" @@ -192,6 +201,20 @@ sub purge { $self->SUPER::purge; } +#------------------------------------------------------------------- + +=head2 purgeCache () + +See WebGUI::Asset::purgeCache() for details. + +=cut + +sub purgeCache { + my $self = shift; + WebGUI::Cache->new($self->session,"view_".$self->getId)->delete; + $self->SUPER::purgeCache; +} + #------------------------------------------------------------------- sub setRatings { my $self = shift; @@ -377,6 +400,14 @@ sub getEditForm { my $self = shift; my $tabform = $self->SUPER::getEditForm(); my $i18n = WebGUI::International->new($self->session,'Asset_Matrix'); + $tabform->getTab("display")->interval( + -name=>"visitorCacheTimeout", + -label=>$i18n->get('visitor cache timeout'), + -hoverHelp=>$i18n->get('visitor cache timeout help'), + -value=>$self->getValue('visitorCacheTimeout'), + -uiLevel=>8, + -defaultValue=>3600 + ); $tabform->getTab("properties")->textarea( -name=>"categories", -label=>$i18n->get('categories'), @@ -905,6 +936,10 @@ sub www_search { #------------------------------------------------------------------- sub view { my $self = shift; + if ($self->session->user->userId eq '1') { + my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; + return $out if $out; + } my (%var); $var{'compare.form'} = $self->getCompareForm; $var{'search.url'} = $self->getUrl("func=search"); @@ -1000,7 +1035,11 @@ sub view { }); } $sth->finish; - return $self->processTemplate(\%var,undef,$self->{_viewTemplate}); + my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate}); + if ($self->session->user->userId eq '1') { + WebGUI::Cache->new($self->session,"view_".$self->getId)->set($out,$self->get("visitorCacheTimeout")); + } + return $out; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Asset/Wobject/MessageBoard.pm b/lib/WebGUI/Asset/Wobject/MessageBoard.pm index 8f9dad0c7..22a58e707 100644 --- a/lib/WebGUI/Asset/Wobject/MessageBoard.pm +++ b/lib/WebGUI/Asset/Wobject/MessageBoard.pm @@ -12,6 +12,7 @@ package WebGUI::Asset::Wobject::MessageBoard; use strict; use Tie::IxHash; +use WebGUI::Cache; use WebGUI::Asset::Wobject; use WebGUI::International; use WebGUI::SQL; @@ -35,7 +36,15 @@ sub definition { namespace=>"MessageBoard", label=>$i18n->get(73), hoverHelp=>$i18n->get('73 description') - } + }, + visitorCacheTimeout => { + tab => "display", + fieldType => "interval", + defaultValue => 3600, + uiLevel => 8, + label => $i18n->get("visitor cache timeout"), + hoverHelp => $i18n->get("visitor cache timeout help") + }, ); push(@{$definition}, { assetName=>$i18n->get('assetName'), @@ -65,10 +74,34 @@ sub prepareView { $self->{_viewTemplate} = $template; } +#------------------------------------------------------------------- + +=head2 purgeCache () + +See WebGUI::Asset::purgeCache() for details. + +=cut + +sub purgeCache { + my $self = shift; + WebGUI::Cache->new($self->session,"view_".$self->getId)->delete; + $self->SUPER::purgeCache; +} #------------------------------------------------------------------- + +=head2 view () + +See WebGUI::Asset::view() for details. + +=cut + sub view { my $self = shift; + if ($self->session->user->userId eq '1') { + my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; + return $out if $out; + } my %var; my $count; my $first; @@ -123,7 +156,11 @@ sub view { $var{'lastpost.label'} = $i18n->get('lastpost'); $var{areMultipleForums} = ($count > 1); $var{forum_loop} = \@forum_loop; - return $self->processTemplate(\%var,undef,$self->{_viewTemplate}); + my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate}); + if ($self->session->user->userId eq '1') { + WebGUI::Cache->new($self->session,"view_".$self->getId)->set($out,$self->get("visitorCacheTimeout")); + } + return $out; } 1; diff --git a/lib/WebGUI/Asset/Wobject/MultiSearch.pm b/lib/WebGUI/Asset/Wobject/MultiSearch.pm index 3997e53f5..973b1acfe 100644 --- a/lib/WebGUI/Asset/Wobject/MultiSearch.pm +++ b/lib/WebGUI/Asset/Wobject/MultiSearch.pm @@ -24,6 +24,7 @@ use Tie::IxHash; use JSON; use WebGUI::International; use WebGUI::SQL; +use WebGUI::Cache; use WebGUI::Asset::Wobject; use WebGUI::Utility; @@ -43,6 +44,14 @@ sub definition { my $definition = shift; my $i18n = WebGUI::International->new($session, "Asset_MultiSearch"); my $properties = { + cacheTimeout => { + tab => "display", + fieldType => "interval", + defaultValue => 3600, + uiLevel => 8, + label => $i18n->get("cache timeout"), + hoverHelp => $i18n->get("cache timeout help") + }, templateId =>{ fieldType=>"template", tab=>"display", @@ -87,6 +96,20 @@ sub prepareView { } +#------------------------------------------------------------------- + +=head2 purgeCache () + +See WebGUI::Asset::purgeCache() for details. + +=cut + +sub purgeCache { + my $self = shift; + WebGUI::Cache->new($self->session,"view_".$self->getId)->delete; + $self->SUPER::purgeCache; +} + #------------------------------------------------------------------- =head2 view ( ) @@ -97,6 +120,10 @@ to be displayed within the page style sub view { my $self = shift; + if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { + my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; + return $out if $out; + } my %var = $self->get(); my $i18n = WebGUI::International->new($self->session, 'Asset_MultiSearch'); @@ -105,7 +132,11 @@ sub view { $var{'search'} = $i18n->get('search'); $var{'submit'} = WebGUI::Form::Submit->new({name=>'SearchSubmit',value=>$i18n->get('submit','WebGUI')})->toHtml(); - return $self->processTemplate(\%var, undef, $self->get("templateId")); + my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate}); + if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { + WebGUI::Cache->new($self->session,"view_".$self->getId)->set($out,$self->get("cacheTimeout")); + } + return $out; } diff --git a/lib/WebGUI/Asset/Wobject/Product.pm b/lib/WebGUI/Asset/Wobject/Product.pm index 1818bdbc4..8f2ca01d0 100644 --- a/lib/WebGUI/Asset/Wobject/Product.pm +++ b/lib/WebGUI/Asset/Wobject/Product.pm @@ -12,6 +12,7 @@ package WebGUI::Asset::Wobject::Product; use strict; use Tie::CPHash; +use WebGUI::Cache; use WebGUI::HTMLForm; use WebGUI::Storage::Image; use WebGUI::SQL; @@ -101,6 +102,14 @@ sub definition { tableName=>'Product', className=>'WebGUI::Asset::Wobject::Product', properties=>{ + cacheTimeout => { + tab => "display", + fieldType => "interval", + defaultValue => 3600, + uiLevel => 8, + label => $i18n->get("cache timeout"), + hoverHelp => $i18n->get("cache timeout help") + }, templateId =>{ fieldType=>"template", defaultValue=>'PBtmpl0000000000000056' @@ -333,6 +342,20 @@ sub purge { #------------------------------------------------------------------- +=head2 purgeCache () + +See WebGUI::Asset::purgeCache() for details. + +=cut + +sub purgeCache { + my $self = shift; + WebGUI::Cache->new($self->session,"view_".$self->getId)->delete; + $self->SUPER::purgeCache; +} + +#------------------------------------------------------------------- + sub purgeRevision { my $self = shift; WebGUI::Storage->get($self->session,$self->get("image1"))->delete if ($self->get("image1")); @@ -737,6 +760,10 @@ sub www_moveSpecificationUp { #------------------------------------------------------------------- sub view { my $self = shift; + if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { + my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; + return $out if $out; + } my (%data, $sth, $file, $segment, %var, @featureloop, @benefitloop, @specificationloop, @accessoryloop, @relatedloop); tie %data, 'Tie::CPHash'; my $brochure = $self->get("brochure"); @@ -879,7 +906,11 @@ sub view { } $sth->finish; $var{relatedproduct_loop} = \@relatedloop; - return $self->processTemplate(\%var, undef, $self->{_viewTemplate}); + my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate}); + if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { + WebGUI::Cache->new($self->session,"view_".$self->getId)->set($out,$self->get("cacheTimeout")); + } + return $out; } 1; diff --git a/lib/WebGUI/Asset/Wobject/SQLReport.pm b/lib/WebGUI/Asset/Wobject/SQLReport.pm index 2fd47139d..ec72d905d 100644 --- a/lib/WebGUI/Asset/Wobject/SQLReport.pm +++ b/lib/WebGUI/Asset/Wobject/SQLReport.pm @@ -18,6 +18,7 @@ use WebGUI::Paginator; use WebGUI::SQL; use WebGUI::Utility; use WebGUI::Asset::Wobject; +use WebGUI::Cache; our @ISA = qw(WebGUI::Asset::Wobject); @@ -40,6 +41,10 @@ sub definition { fieldType=>"template", defaultValue=>'PBtmpl0000000000000059' }, + cacheTimeout=>{ + fieldType=>"interval", + defaultValue=>0 + }, paginateAfter=>{ fieldType=>"integer", defaultValue=>50 @@ -170,6 +175,13 @@ sub getEditForm { -hoverHelp=>$i18n->get('16 description'), -value=>$self->getValue("debugMode") ); + $tabform->getTab("display")->interval( + -name=>"cacheTimeout", + -label=>$i18n->get('cache timeout'), + -hoverHelp=>$i18n->get('cache timeout description'), + -uiLevel => 8, + -value=>$self->getValue("cacheTimeout") + ); # Add toggleQuery javascript $tabform->getTab("properties")->raw(qq| @@ -279,9 +291,27 @@ sub prepareView { } +#------------------------------------------------------------------- + +=head2 purgeCache () + +See WebGUI::Asset::purgeCache() for details. + +=cut + +sub purgeCache { + my $self = shift; + WebGUI::Cache->new($self->session,"view_".$self->getId)->delete; + $self->SUPER::purgeCache; +} + #------------------------------------------------------------------- sub view { my $self = shift; + if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { + my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; + return $out if $out; + } # Initiate an empty debug loop $self->{_debug_loop} = [] ; @@ -294,7 +324,11 @@ sub view { # Add debug loop to template vars $var->{'debug_loop'} = $self->{_debug_loop}; #use Data::Dumper; return '

'.Dumper($var).'
'; - return $self->processTemplate($var, undef, $self->{_viewTemplate}); + my $out = $self->processTemplate($var,undef,$self->{_viewTemplate}); + if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { + WebGUI::Cache->new($self->session,"view_".$self->getId)->set($out,$self->get("visitorCacheTimeout")); + } + return $out; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Asset/Wobject/StockData.pm b/lib/WebGUI/Asset/Wobject/StockData.pm index 982bfa711..c3c957055 100644 --- a/lib/WebGUI/Asset/Wobject/StockData.pm +++ b/lib/WebGUI/Asset/Wobject/StockData.pm @@ -463,16 +463,5 @@ sub www_displayStock { return $self->processTemplate($var, $self->get("displayTemplateId")); } -#------------------------------------------------------------------- -=head2 www_view ( ) - -Overwrite www_view method and call the superclass object, passing in a 1 to disable cache - -=cut - -sub www_view { - my $self = shift; - $self->SUPER::www_view(1); -} 1; diff --git a/lib/WebGUI/Asset/Wobject/Survey.pm b/lib/WebGUI/Asset/Wobject/Survey.pm index a41135cda..84ea7f792 100644 --- a/lib/WebGUI/Asset/Wobject/Survey.pm +++ b/lib/WebGUI/Asset/Wobject/Survey.pm @@ -1213,18 +1213,6 @@ sub www_respond { } -#------------------------------------------------------------------- -=head2 www_view ( ) - -Overwrite www_view method and call the superclass object, passing in a 1 to disable cache - -=cut - -sub www_view { - my $self = shift; - $self->SUPER::www_view(1); -} - #------------------------------------------------------------------- sub www_viewGradebook { my $self = shift; diff --git a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm index 96c88b4e9..fca07594f 100644 --- a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm +++ b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm @@ -69,6 +69,14 @@ sub definition { tie %properties, 'Tie::IxHash'; my $i18n = WebGUI::International->new($session,'Asset_SyndicatedContent'); %properties = ( + cacheTimeout => { + tab => "display", + fieldType => "interval", + defaultValue => 3600, + uiLevel => 8, + label => $i18n->get("cache timeout"), + hoverHelp => $i18n->get("cache timeout help") + }, templateId =>{ tab=>"display", fieldType=>'template', @@ -485,6 +493,20 @@ sub prepareView { } +#------------------------------------------------------------------- + +=head2 purgeCache () + +See WebGUI::Asset::purgeCache() for details. + +=cut + +sub purgeCache { + my $self = shift; + WebGUI::Cache->new($self->session,"view_".$self->getId)->delete; + $self->SUPER::purgeCache; +} + #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ =head2 view() @@ -494,9 +516,11 @@ Returns the rendered output of the wobject. sub view { my $self = shift; + if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { + my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; + return $out if $out; + } my $rssFlavor = shift; - $self->logView() if ($self->session->setting->get("passiveProfilingEnabled")); - my $maxHeadlines = $self->get('maxHeadlines') || 1000000; my @urls = split(/\s+/,$self->get('rssUrl')); return $self->processTemplate({},$self->get('templateId')) unless (scalar(@urls)); @@ -535,7 +559,11 @@ sub view { return $rss; } else { - return $self->processTemplate(\%var,undef, $self->{_viewTemplate}); + my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate}); + if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { + WebGUI::Cache->new($self->session,"view_".$self->getId)->set($out,$self->get("cacheTimeout")); + } + return $out; } } diff --git a/lib/WebGUI/Asset/Wobject/_NewWobject.skeleton b/lib/WebGUI/Asset/Wobject/_NewWobject.skeleton index e9c4cfc91..b5f2048c6 100644 --- a/lib/WebGUI/Asset/Wobject/_NewWobject.skeleton +++ b/lib/WebGUI/Asset/Wobject/_NewWobject.skeleton @@ -186,19 +186,4 @@ adminConsole views. # WebGUI::International::get("edit_title","NewWobject")); #} -#------------------------------------------------------------------- -=head2 www_view ( ) - -Override www_view method and call the superclass's object method, passing -in a 1 to disable wobject-level cache. Only use this method if you want -to explicitly disable caching, or do something else when /yourWobjectUrl?func=view or just /yourWobjectUrl is requested. - -=cut - -sub www_view { - my $self = shift; - return $self->SUPER::www_view(1); - # default: return $self->SUPER::www_view(); -} - 1; diff --git a/lib/WebGUI/AssetBranch.pm b/lib/WebGUI/AssetBranch.pm index 3d686a354..3d2d8cd06 100644 --- a/lib/WebGUI/AssetBranch.pm +++ b/lib/WebGUI/AssetBranch.pm @@ -158,22 +158,6 @@ sub www_editBranch { -afterEdit=>'op=editPage;npp='.$self->session->form->process("npp"), -subtext=>'
'.$i18n->get("change").' '.WebGUI::Form::yesNo($self->session,{name=>"change_printableStyleTemplateId"}) ); - $tabform->getTab("display")->interval( - -name=>"cacheTimeout", - -label=>$i18n->get(895), - -hoverHelp=>$i18n->get('895 description','Asset_Wobject'), - -value=>$self->getValue("cacheTimeout"), - -uiLevel=>8, - -subtext=>'
'.$i18n->get("change").' '.WebGUI::Form::yesNo($self->session,{name=>"change_cacheTimeout"}) - ); - $tabform->getTab("display")->interval( - -name=>"cacheTimeoutVisitor", - -label=>$i18n->get(896), - -hoverHelp=>$i18n->get('896 description','Asset_Wobject'), - -value=>$self->getValue("cacheTimeoutVisitor"), - -uiLevel=>8, - -subtext=>'
'.$i18n->get("change").' '.WebGUI::Form::yesNo($self->session,{name=>"change_cacheTimeoutVisitor"}) - ); $tabform->addTab("security",$i18n->get(107),6); $tabform->getTab("security")->yesNo( -name=>"encryptPage", @@ -277,8 +261,6 @@ sub www_editBranchSave { $data{displayTitle} = $self->session->form->yesNo("displayTitle") if ($self->session->form->yesNo("change_displayTitle")); $data{styleTemplateId} = $self->session->form->template("styleTemplateId") if ($self->session->form->yesNo("change_styleTemplateId")); $data{printableStyleTemplateId} = $self->session->form->template("printableStyleTemplateId") if ($self->session->form->yesNo("change_printableStyleTemplateId")); - $data{cacheTimeout} = $self->session->form->interval("cacheTimeout") if ($self->session->form->yesNo("change_cacheTimeout")); - $data{cacheTimeoutVisitor} = $self->session->form->interval("cacheTimeoutVisitor") if ($self->session->form->yesNo("change_cacheTimeoutVisitor")); $data{encryptPage} = $self->session->form->yesNo("encryptPage") if ($self->session->form->yesNo("change_encryptPage")); $data{ownerUserId} = $self->session->form->selectBox("ownerUserId") if ($self->session->form->yesNo("change_ownerUserId")); $data{groupIdView} = $self->session->form->group("groupIdView") if ($self->session->form->yesNo("change_groupIdView")); diff --git a/lib/WebGUI/AssetExportHtml.pm b/lib/WebGUI/AssetExportHtml.pm index 3f130da9b..f9234b268 100644 --- a/lib/WebGUI/AssetExportHtml.pm +++ b/lib/WebGUI/AssetExportHtml.pm @@ -96,7 +96,6 @@ sub exportAsHtml { # Change the stuff we need to change to do the export my $session = WebGUI::Session->open($self->session->config->getWebguiRoot, $self->session->config->getFilename); $session->user({userId=>$userId}) unless ($userId eq $self->session->user->userId); - $self->{_properties}{cacheTimeout} = $self->{_properties}{cacheTimeoutVisitor} = 1; # Generate the page my $content = $self->www_view; diff --git a/lib/WebGUI/Help/Asset_Article.pm b/lib/WebGUI/Help/Asset_Article.pm index ef3be28a9..7a764ead2 100644 --- a/lib/WebGUI/Help/Asset_Article.pm +++ b/lib/WebGUI/Help/Asset_Article.pm @@ -5,6 +5,11 @@ our $HELP = { title => '61', body => '71', fields => [ + { + title => 'cache timeout', + namespace => 'Asset_Article', + description => 'cache timeout help' + }, { title => '72', description => 'article template description', diff --git a/lib/WebGUI/Help/Asset_Collaboration.pm b/lib/WebGUI/Help/Asset_Collaboration.pm index 214beef07..b89a20952 100644 --- a/lib/WebGUI/Help/Asset_Collaboration.pm +++ b/lib/WebGUI/Help/Asset_Collaboration.pm @@ -5,6 +5,11 @@ our $HELP = { title => 'collaboration add/edit title', body => 'collaboration add/edit body', fields => [ + { + title => 'visitor cache timeout', + namespace => 'Asset_Collaboration', + description => 'visitor cache timeout help' + }, { title => 'display last reply', description => 'display last reply description', diff --git a/lib/WebGUI/Help/Asset_EventsCalendar.pm b/lib/WebGUI/Help/Asset_EventsCalendar.pm index 64b8c2043..f5278e001 100644 --- a/lib/WebGUI/Help/Asset_EventsCalendar.pm +++ b/lib/WebGUI/Help/Asset_EventsCalendar.pm @@ -5,6 +5,11 @@ our $HELP = { title => '61', body => '71', fields => [ + { + title => 'visitor cache timeout', + namespace => 'Asset_EventsCalendar', + description => 'visitor cache timeout help' + }, { title => '507', description => '507 description', diff --git a/lib/WebGUI/Help/Asset_File.pm b/lib/WebGUI/Help/Asset_File.pm index f6dfe2826..9a1bf73a1 100644 --- a/lib/WebGUI/Help/Asset_File.pm +++ b/lib/WebGUI/Help/Asset_File.pm @@ -6,6 +6,11 @@ our $HELP = { title => 'file add/edit title', body => 'file add/edit body', fields => [ + { + title => 'cache timeout', + namespace => 'Asset_File', + description => 'cache timeout help' + }, { title => 'new file', description => 'new file description', diff --git a/lib/WebGUI/Help/Asset_Folder.pm b/lib/WebGUI/Help/Asset_Folder.pm index 85b9ef2d4..d0cab942f 100644 --- a/lib/WebGUI/Help/Asset_Folder.pm +++ b/lib/WebGUI/Help/Asset_Folder.pm @@ -6,6 +6,11 @@ our $HELP = { title => 'folder add/edit title', body => 'folder add/edit body', fields => [ + { + title => 'visitor cache timeout', + namespace => 'Asset_Folder', + description => 'visitor cache timeout help' + }, { title => 'folder template title', description => 'folder template description', diff --git a/lib/WebGUI/Help/Asset_HttpProxy.pm b/lib/WebGUI/Help/Asset_HttpProxy.pm index b1395f4ac..a847fd37a 100644 --- a/lib/WebGUI/Help/Asset_HttpProxy.pm +++ b/lib/WebGUI/Help/Asset_HttpProxy.pm @@ -30,6 +30,11 @@ our $HELP = { description => 'http proxy template title description', namespace => 'Asset_HttpProxy', }, + { + title => 'cache timeout', + description => 'cache timeout description', + namespace => 'Asset_HttpProxy', + }, { title => '6', description => '6 description', diff --git a/lib/WebGUI/Help/Asset_Matrix.pm b/lib/WebGUI/Help/Asset_Matrix.pm index 75ec16df4..52d5b6736 100644 --- a/lib/WebGUI/Help/Asset_Matrix.pm +++ b/lib/WebGUI/Help/Asset_Matrix.pm @@ -5,6 +5,11 @@ our $HELP = { title => 'add/edit help title', body => 'add/edit help body', fields => [ + { + title => 'visitor cache timeout', + namespace => 'Asset_Matrix', + description => 'visitor cache timeout help' + }, { title => 'categories', description => 'categories description', diff --git a/lib/WebGUI/Help/Asset_MessageBoard.pm b/lib/WebGUI/Help/Asset_MessageBoard.pm index 3ca400d66..0ec70eae5 100644 --- a/lib/WebGUI/Help/Asset_MessageBoard.pm +++ b/lib/WebGUI/Help/Asset_MessageBoard.pm @@ -5,6 +5,11 @@ our $HELP = { title => '61', body => '71', fields => [ + { + title => 'visitor cache timeout', + namespace => 'Asset_MessageBoard', + description => 'visitor cache timeout help' + }, { title => '73', namespace => 'Asset_MessageBoard', diff --git a/lib/WebGUI/Help/Asset_MultiSearch.pm b/lib/WebGUI/Help/Asset_MultiSearch.pm index fffd8e462..22ef67ccc 100644 --- a/lib/WebGUI/Help/Asset_MultiSearch.pm +++ b/lib/WebGUI/Help/Asset_MultiSearch.pm @@ -5,6 +5,11 @@ our $HELP = { title => 'multisearch add/edit title', body => 'multisearch add/edit body', fields => [ + { + title => 'cache timeout', + namespace => 'Asset_MultiSearch', + description => 'cache timeout help' + }, { title => 'MultiSearch Template', description => 'MultiSearch Template description', diff --git a/lib/WebGUI/Help/Asset_Product.pm b/lib/WebGUI/Help/Asset_Product.pm index 89c014ff5..4701f574a 100644 --- a/lib/WebGUI/Help/Asset_Product.pm +++ b/lib/WebGUI/Help/Asset_Product.pm @@ -5,6 +5,11 @@ our $HELP = { title => '38', body => '39', fields => [ + { + title => 'cache timeout', + namespace => 'Asset_Product', + description => 'cache timeout help' + }, { title => '62', description => '62 description', diff --git a/lib/WebGUI/Help/Asset_SQLReport.pm b/lib/WebGUI/Help/Asset_SQLReport.pm index 550ed2feb..a61e09db2 100644 --- a/lib/WebGUI/Help/Asset_SQLReport.pm +++ b/lib/WebGUI/Help/Asset_SQLReport.pm @@ -10,6 +10,11 @@ our $HELP = { description => '72 description', namespace => 'Asset_SQLReport', }, + { + title => 'cache timeout', + description => 'cache timeout description', + namespace => 'Asset_SQLReport', + }, { title => '16', description => '16 description', diff --git a/lib/WebGUI/Help/Asset_SyndicatedContent.pm b/lib/WebGUI/Help/Asset_SyndicatedContent.pm index fb03d448a..d82f7801a 100644 --- a/lib/WebGUI/Help/Asset_SyndicatedContent.pm +++ b/lib/WebGUI/Help/Asset_SyndicatedContent.pm @@ -5,6 +5,11 @@ our $HELP = { title => '61', body => '71', fields => [ + { + title => 'cache timeout', + namespace => 'Asset_SyndicatedContent', + description => 'cache timeout help' + }, { title => '72', description => '72 description', diff --git a/lib/WebGUI/Help/Asset_Wobject.pm b/lib/WebGUI/Help/Asset_Wobject.pm index f5d760fa1..0e7564650 100644 --- a/lib/WebGUI/Help/Asset_Wobject.pm +++ b/lib/WebGUI/Help/Asset_Wobject.pm @@ -52,18 +52,6 @@ our $HELP = { description => '85 description', namespace => 'Asset_Wobject', }, - { - title => '895', - description => '895 description', - namespace => 'Asset_Wobject', - uiLevel => 8, - }, - { - title => '896', - description => '896 description', - namespace => 'Asset_Wobject', - uiLevel => 8, - }, ], related => [ { diff --git a/lib/WebGUI/i18n/English/Asset_Article.pm b/lib/WebGUI/i18n/English/Asset_Article.pm index 46edd598b..524dac56c 100644 --- a/lib/WebGUI/i18n/English/Asset_Article.pm +++ b/lib/WebGUI/i18n/English/Asset_Article.pm @@ -1,6 +1,16 @@ package WebGUI::i18n::English::Asset_Article; our $I18N = { + 'cache timeout' => { + message => q|Cache Timeout|, + lastUpdated => 0 + }, + + 'cache timeout help' => { + message => q|Since all users will see this asset the same way, we can cache it for long periods of time to increase performance. How long should we cache it?

UI Level: 8|, + lastUpdated => 0 + }, + '11' => { message => q|(Select "Yes" only if you aren't adding <br> manually.)|, lastUpdated => 1031514049 diff --git a/lib/WebGUI/i18n/English/Asset_Collaboration.pm b/lib/WebGUI/i18n/English/Asset_Collaboration.pm index 66e1c162b..278f79cba 100644 --- a/lib/WebGUI/i18n/English/Asset_Collaboration.pm +++ b/lib/WebGUI/i18n/English/Asset_Collaboration.pm @@ -2,6 +2,16 @@ package WebGUI::i18n::English::Asset_Collaboration; our $I18N = { + 'visitor cache timeout' => { + message => q|Visitor Cache Timeout|, + lastUpdated => 0 + }, + + 'visitor cache timeout help' => { + message => q|Since all visitors will see this asset the same way, we can cache it to increase performance. How long should we cache it?

UI Level: 8|, + lastUpdated => 0 + }, + 'karma rank' => { message => q|Karma Rank|, context => q|a label used in sorting threads by karma divided by karma scale|, diff --git a/lib/WebGUI/i18n/English/Asset_EventsCalendar.pm b/lib/WebGUI/i18n/English/Asset_EventsCalendar.pm index bc2e03836..f2fd6fea7 100644 --- a/lib/WebGUI/i18n/English/Asset_EventsCalendar.pm +++ b/lib/WebGUI/i18n/English/Asset_EventsCalendar.pm @@ -2,6 +2,16 @@ package WebGUI::i18n::English::Asset_EventsCalendar; our $I18N = { + 'visitor cache timeout' => { + message => q|Visitor Cache Timeout|, + lastUpdated => 0 + }, + + 'visitor cache timeout help' => { + message => q|Since all visitors will see this asset the same way, we can cache it to increase performance. How long should we cache it?

UI Level: 8|, + lastUpdated => 0 + }, + 'january' => { message => q|January|, lastUpdated => 1133711787 diff --git a/lib/WebGUI/i18n/English/Asset_File.pm b/lib/WebGUI/i18n/English/Asset_File.pm index ed37ac493..8c18c593b 100644 --- a/lib/WebGUI/i18n/English/Asset_File.pm +++ b/lib/WebGUI/i18n/English/Asset_File.pm @@ -1,6 +1,16 @@ package WebGUI::i18n::English::Asset_File; our $I18N = { + 'cache timeout' => { + message => q|Cache Timeout|, + lastUpdated => 0 + }, + + 'cache timeout help' => { + message => q|Since all users will see this asset the same way, we can cache it for long periods of time to increase performance. How long should we cache it?

UI Level: 8|, + lastUpdated => 0 + }, + 'file add/edit title' => { message => q|File, Add/Edit|, lastUpdated => 1106683494, diff --git a/lib/WebGUI/i18n/English/Asset_Folder.pm b/lib/WebGUI/i18n/English/Asset_Folder.pm index ef571c332..e42246d78 100644 --- a/lib/WebGUI/i18n/English/Asset_Folder.pm +++ b/lib/WebGUI/i18n/English/Asset_Folder.pm @@ -2,6 +2,16 @@ package WebGUI::i18n::English::Asset_Folder; our $I18N = { + 'visitor cache timeout' => { + message => q|Visitor Cache Timeout|, + lastUpdated => 0 + }, + + 'visitor cache timeout help' => { + message => q|Since all visitors will see this asset the same way, we can cache it to increase performance. How long should we cache it?

UI Level: 8|, + lastUpdated => 0 + }, + '847' => { message => qq|Go back to the current page.|, lastUpdated => 1039587250, diff --git a/lib/WebGUI/i18n/English/Asset_HttpProxy.pm b/lib/WebGUI/i18n/English/Asset_HttpProxy.pm index 63fe482f3..e21fce423 100644 --- a/lib/WebGUI/i18n/English/Asset_HttpProxy.pm +++ b/lib/WebGUI/i18n/English/Asset_HttpProxy.pm @@ -1,6 +1,16 @@ package WebGUI::i18n::English::Asset_HttpProxy; our $I18N = { + 'cache timeout description' => { + message => q|How long should the proxy cache a page, so that if it's requested again, it won't have to refetch it?|, + lastUpdated => 1047837230 + }, + + 'cache timeout' => { + message => q|Cache Timeout|, + lastUpdated => 1047837230 + }, + '6' => { message => q|Remove style?|, lastUpdated => 1047837230 diff --git a/lib/WebGUI/i18n/English/Asset_Matrix.pm b/lib/WebGUI/i18n/English/Asset_Matrix.pm index 4949b07ef..b548b8db7 100644 --- a/lib/WebGUI/i18n/English/Asset_Matrix.pm +++ b/lib/WebGUI/i18n/English/Asset_Matrix.pm @@ -1,6 +1,16 @@ package WebGUI::i18n::English::Asset_Matrix; our $I18N = { + 'visitor cache timeout' => { + message => q|Visitor Cache Timeout|, + lastUpdated => 0 + }, + + 'visitor cache timeout help' => { + message => q|Since all visitors will see this asset the same way, we can cache it to increase performance. How long should we cache it?

UI Level: 8|, + lastUpdated => 0 + }, + 'comparison template help body' => { lastUpdated => 0, message => q|

The following template variables are available in the comparison template.

diff --git a/lib/WebGUI/i18n/English/Asset_MessageBoard.pm b/lib/WebGUI/i18n/English/Asset_MessageBoard.pm index d2b821674..6c1992b12 100644 --- a/lib/WebGUI/i18n/English/Asset_MessageBoard.pm +++ b/lib/WebGUI/i18n/English/Asset_MessageBoard.pm @@ -1,6 +1,16 @@ package WebGUI::i18n::English::Asset_MessageBoard; our $I18N = { + 'visitor cache timeout' => { + message => q|Visitor Cache Timeout|, + lastUpdated => 0 + }, + + 'visitor cache timeout help' => { + message => q|Since all visitors will see this asset the same way, we can cache it to increase performance. How long should we cache it?

UI Level: 8|, + lastUpdated => 0 + }, + '74' => { message => q|The following is the list of template variables available in message board templates.

diff --git a/lib/WebGUI/i18n/English/Asset_MultiSearch.pm b/lib/WebGUI/i18n/English/Asset_MultiSearch.pm index 4963e2c9d..1a560b445 100644 --- a/lib/WebGUI/i18n/English/Asset_MultiSearch.pm +++ b/lib/WebGUI/i18n/English/Asset_MultiSearch.pm @@ -2,6 +2,16 @@ package WebGUI::i18n::English::Asset_MultiSearch; our $I18N = { + 'cache timeout' => { + message => q|Cache Timeout|, + lastUpdated => 0 + }, + + 'cache timeout help' => { + message => q|Since all users will see this asset the same way, we can cache it for long periods of time to increase performance. How long should we cache it?

UI Level: 8|, + lastUpdated => 0 + }, + 'MultiSearch Template' => { message => q|MultiSearch Template|, lastUpdated => 1133619940, diff --git a/lib/WebGUI/i18n/English/Asset_Product.pm b/lib/WebGUI/i18n/English/Asset_Product.pm index a5d851dac..7b037af75 100644 --- a/lib/WebGUI/i18n/English/Asset_Product.pm +++ b/lib/WebGUI/i18n/English/Asset_Product.pm @@ -1,6 +1,16 @@ package WebGUI::i18n::English::Asset_Product; our $I18N = { + 'cache timeout' => { + message => q|Cache Timeout|, + lastUpdated => 0 + }, + + 'cache timeout help' => { + message => q|Since all users will see this asset the same way, we can cache it for long periods of time to increase performance. How long should we cache it?

UI Level: 8|, + lastUpdated => 0 + }, + '33' => { message => q|Related Products|, lastUpdated => 1031514049 diff --git a/lib/WebGUI/i18n/English/Asset_SQLReport.pm b/lib/WebGUI/i18n/English/Asset_SQLReport.pm index 12506e710..6dcc85db3 100644 --- a/lib/WebGUI/i18n/English/Asset_SQLReport.pm +++ b/lib/WebGUI/i18n/English/Asset_SQLReport.pm @@ -1,6 +1,16 @@ package WebGUI::i18n::English::Asset_SQLReport; our $I18N = { + 'cache timeout description' => { + message => q|How long should we cache the results of the query before fetching it again?|, + lastUpdated => 1047837230 + }, + + 'cache timeout' => { + message => q|Cache Timeout|, + lastUpdated => 1047837230 + }, + '11' => { message => q|Debug: Error: There was a problem with the query.|, lastUpdated => 1031514049 diff --git a/lib/WebGUI/i18n/English/Asset_SyndicatedContent.pm b/lib/WebGUI/i18n/English/Asset_SyndicatedContent.pm index cf87a6414..2977ded25 100644 --- a/lib/WebGUI/i18n/English/Asset_SyndicatedContent.pm +++ b/lib/WebGUI/i18n/English/Asset_SyndicatedContent.pm @@ -1,6 +1,16 @@ package WebGUI::i18n::English::Asset_SyndicatedContent; our $I18N = { + 'cache timeout' => { + message => q|Cache Timeout|, + lastUpdated => 0 + }, + + 'cache timeout help' => { + message => q|Since all users will see this asset the same way, we can cache it for long periods of time to increase performance. How long should we cache it?

UI Level: 8|, + lastUpdated => 0 + }, + 'get syndicated content' => { 'lastUpdated' => 0, 'message' => 'Get Syndicated Content', diff --git a/lib/WebGUI/i18n/English/Asset_Wobject.pm b/lib/WebGUI/i18n/English/Asset_Wobject.pm index 39f74708f..21deaf7dd 100644 --- a/lib/WebGUI/i18n/English/Asset_Wobject.pm +++ b/lib/WebGUI/i18n/English/Asset_Wobject.pm @@ -77,15 +77,6 @@ is displayed as part of a Layout Asset, the Layout Asset's Style Template lastUpdated => 1119410887, }, - '895 description' => { - message => q|The amount of time this page should remain cached for registered users.|, - lastUpdated => 1119410887, - }, - - '896 description' => { - message => q|The amount of time this page should remain cached for visitors.|, - lastUpdated => 1119410887, - }, '42' => { lastUpdated => 1031514049, @@ -111,14 +102,6 @@ is displayed as part of a Layout Asset, the Layout Asset's Style Template lastUpdated => 1031514049, message => q|Description| }, - '895' => { - lastUpdated => 1056292971, - message => q|Cache Timeout| - }, - '896' => { - lastUpdated => 1056292980, - message => q|Cache Timeout (Visitors)| - }, '664' => { lastUpdated => 1031514049, message => q|Wobject, Delete|