added page caching

This commit is contained in:
JT Smith 2003-06-22 20:18:58 +00:00
parent 5567669b4f
commit 1eb72cc633
6 changed files with 74 additions and 25 deletions

View file

@ -8,6 +8,13 @@ versions. Be sure to heed the warnings contained herein as they will
save you many hours of grief.
5.4.0
--------------------------------------------------------------------
* Page caching has been moved to individual pages rather than a
global setting. As a result all pages have been defaulted
back to the original setting.
5.3.2
--------------------------------------------------------------------
* On some systems the ^\; macro is not specified properly in the

View file

@ -58,3 +58,20 @@ delete from international where languageId=1 and namespace='WebGUI' and internat
insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (634,1,'WebGUI','<B>Default Home Page</B><BR>Some really small sites don\'t have a home page, but instead like to use one of their internal pages like \"About Us\" or \"Company Information\" as their home page. For that reason, you can set the default page of your site to any page in the site. That page will be the one people go to if they type in just your URL http://www.mywebguisite.com, or if they click on the Home link generated by the ^H; macro. \r\n<P><B>Not Found Page</B><BR>If a page that a user requests is not found in the system, the user can be redirected to the home page or to an error page where they can attempt to find what they were looking for. You decide which is better for your users. \r\n<P><B>Document Type Declaration</B><BR>These days it is very common to have a wide array of browsers accessing your site, including automated browsers like search engine spiders. Many of those browsers want to know what kind of content you are serving. The doctype tag allows you to specify that. By default WebGUI generates HTML 4.0 compliant content. \r\n<P><B>Favicon</B><BR>An icon that appears on Internet Explorer short cuts such as your \"Favorites\". To learn more about Favicon <A href=\"http://msdn.microsoft.com/workshop/author/dhtml/howto/shortcuticon.asp\">click here</A>. \r\n<P><B>Site Icon</B><BR>An icon that appears in the URL bar of most modern browsers. It may also appear in the bookmarks of the browser. The image must be 16x16 pixels. \r\n<P><B>Add edit stamp to posts?</B><BR>Typically if a user edits a post on a discussion, a stamp is added to that post to identify who made the edit, and at what time. On some sites that information is not necessary, therefore you can turn it off here. \r\n<P><B>Filter Contributed HTML</B><BR>Especially when running a public site where anybody can post to your message boards or user submission systems, it is often a good idea to filter their content for malicious code that can harm the viewing experience of your visitors; And in some circumstances, it can even cause security problems. Use this setting to select the level of filtering you wish to apply. \r\n<P><B>Maximum Attachment Size</B><BR>The size (in kilobytes) of the maximum allowable attachment to be uploaded to your system. \r\n<P><B>Max Image Size</B><BR>If images are uploaded to your system that are bigger than the max image size, then they will be resized to the max image size. The max image size is measured in pixels and will use the size of the longest side of the image to determine if the limit has been reached. \r\n<P><B>Thumbnail Size</B><BR>When images are uploaded to your system, they will automatically have thumbnails generated at the size specified here (unless overridden on a case-by-case basis). Thumbnail size is measured in pixels. \r\n<P><B>Snippet Preview Length</B><BR>How many characters of a snippet should be displayed in the collateral management system main listing. \r\n<P><B>Text Area Rows</B><BR>Some sites wish to control the size of the forms that WebGUI generates. With this setting you can specify how many rows of characters will be displayed in textareas on the site. \r\n<P><B>Text Area Columns</B><BR>Some sites wish to control the size of the forms that WebGUI generates. With this setting you can specify how many columns of characters will be displayed in textareas on the site. \r\n<P><B>Text Box Size</B><BR>Some sites wish to control the size of the forms that WebGUI generates. With this setting you can specify how characters can be displayed at once in text boxes on the site. \r\n<P><B>Page Cache Timeout</B><BR>The amount of time pages should remain cached for registered users. \r\n<P><B>Page Cache Timeout (Visitors)</B><BR>The amount of time pages should remain cached for visitors. \r\n<P><B>NOTE:</B> Page caching is only available if your administrator has installed the Cache::FileCache Perl module. Using page caching can improve site performance by as much as 1000%.&nbsp;<BR><BR><B>Wobject Privileges</B><BR>Choose \'Yes\' to enable privileges at the Wobject level.&nbsp; By default, Wobjects are set to inherit page level privileges</P>', 1056055394,NULL);
delete from settings where name='wobjectPrivileges';
insert into settings (name,value) values ('wobjectPrivileges','0');
delete from settings where name='cachePages';
delete from settings where name='cachePagesVisitor';
alter table page add column cacheTimeout int not null default 60;
alter table page add column cacheTimeoutVisitor int not null default 600;
delete from international where languageId=1 and namespace='WebGUI' and internationalId=606;
insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (606,1,'WebGUI','Think of pages as containers for content. For instance, if you want to write a letter to the editor of your favorite magazine you\'d get out a notepad (or open a word processor) and start filling it with your thoughts. The same is true with WebGUI. Create a page, then add your content to the page.\r\n<p>\r\n\r\n<b>Title</b><br>\r\nThe title of the page is what your users will use to navigate through the site. Titles should be descriptive, but not very long.\r\n<p>\r\n\r\n\r\n<b>Menu Title</b><br>\r\nA shorter or altered title to appear in navigation. If left blank this will default to <i>Title</i>.\r\n<p>\r\n\r\n<b>Page URL</b><br>\r\nWhen you create a page a URL for the page is generated based on the page title. If you are unhappy with the URL that was chosen, you can change it here.\r\n<p>\r\n\r\n<b>Redirect URL</b><br>\r\nWhen this page is visited, the user will be redirected to the URL specified here. \r\n<p>\r\n<b>NOTE:</b> The redirects will be disabled while in admin mode in order to make it easier to edit the properties of the page.\r\n<p>\r\n\r\n\r\n<b>Hide from navigation?</b><br>\r\nSelect yes to hide this page from the navigation.\r\n<p>\r\n<B>NOTE:</b> This will not hide the page from the page tree (Administrative functions... &gt; Manage page tree.), only from navigation macros.\r\n<p>\r\n\r\n<b>Open in new window?</b><br>\r\nSelect yes to open this page in a new window. This is often used in conjunction with the <b>Redirect URL</b> parameter.\r\n<p>\r\n\r\n\r\n\r\n<b>Language</b><br/>\r\nChoose the default language for this page. All WebGUI generated messages will appear in that language and the character set will be changed to the character set for that language.\r\n<p/>\r\n\r\n<P><B>Cache Timeout</B><BR>The amount of time this page should remain cached for registered users. \r\n\r\n<P><B>Cache Timeout (Visitors)</B><BR>The amount of time this page should remain cached for visitors. \r\n\r\n<P><B>NOTE:</B> Page caching is only available if your administrator has installed the Cache::FileCache Perl module. Using page caching can improve site performance by as much as 1000%.&nbsp;\r\n\r\n\r\n<b>Template</b><br>\r\nBy default, WebGUI has one big content area to place wobjects. However, by specifying a template other than the default you can sub-divide the content area into several sections.\r\n<p>\r\n\r\n<b>Synopsis</b><br>\r\nA short description of a page. It is used to populate default descriptive meta tags as well as to provide descriptions on Site Maps.\r\n<p>\r\n\r\n<b>Meta Tags</b><br>\r\nMeta tags are used by some search engines to associate key words to a particular page. There is a great site called <a href="http://www.metatagbuilder.com/">Meta Tag Builder</a> that will help you build meta tags if you\'ve never done it before.\r\n<p>\r\n\r\n<i>Advanced Users:</i> If you have other things (like JavaScript) you usually put in the area of your pages, you may put them here as well.\r\n<p>\r\n\r\n<b>Use default meta tags?</b><br>\r\nIf you don\'t wish to specify meta tags yourself, WebGUI can generate meta tags based on the page title and your company\'s name. Check this box to enable the WebGUI-generated meta tags.\r\n<p>\r\n\r\n\r\n<b>Style</b><br>\r\nBy default, when you create a page, it inherits a few traits from its parent. One of those traits is style. Choose from the list of styles if you would like to change the appearance of this page. See <i>Add Style</i> for more details.\r\n<p>\r\n\r\nIf you select "Yes" below the style pull-down menu, all of the pages below this page will take on the style you\'ve chosen for this page.\r\n<p>\r\n\r\n<b>Start Date</b><br>\r\nThe date when users may begin viewing this page. Note that before this date only content managers with the rights to edit this page will see it.\r\n<p>\r\n\r\n<b>End Date</b><br>\r\nThe date when users will stop viewing this page. Note that after this date only content managers with the rights to edit this page will see it.\r\n<p>\r\n\r\n\r\n<b>Owner</b><br>\r\nThe owner of a page is usually the person who created the page. This user always has full edit and viewing rights on the page.\r\n<p>\r\n<b>NOTE:</b> The owner can only be changed by an administrator.\r\n<p>\r\n\r\n\r\n<b>Who can view?</b><br>\r\nChoose which group can view this page. If you want both visitors and registered users to be able to view the page then you should choose the "Everybody" group.\r\n<p>\r\n\r\n<b>Who can edit?</b><br>\r\nChoose the group that can edit this page. The group assigned editing rights can also always view the page.\r\n<p>\r\n\r\nYou can optionally recursively give these privileges to all pages under this page.\r\n<p>\r\n\r\n<b>What next?</b><br/>\r\nIf you leave this on the default setting you\'ll be redirected to the new page after creating it.\r\n<p/>', 1056293101,NULL);
delete from international where languageId=1 and namespace='WebGUI' and internationalId=896;
insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (896,1,'WebGUI','Cache Timeout (Visitors)', 1056292980,NULL);
delete from international where languageId=1 and namespace='WebGUI' and internationalId=895;
insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (895,1,'WebGUI','Cache Timeout', 1056292971,NULL);
delete from international where languageId=1 and namespace='WebGUI' and internationalId=634;
insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (634,1,'WebGUI','<B>Default Home Page</B><BR>Some really small sites don\'t have a home page, but instead like to use one of their internal pages like "About Us" or "Company Information" as their home page. For that reason, you can set the default page of your site to any page in the site. That page will be the one people go to if they type in just your URL http://www.mywebguisite.com, or if they click on the Home link generated by the ^H; macro. \r\n<P><B>Not Found Page</B><BR>If a page that a user requests is not found in the system, the user can be redirected to the home page or to an error page where they can attempt to find what they were looking for. You decide which is better for your users. \r\n<P><B>Document Type Declaration</B><BR>These days it is very common to have a wide array of browsers accessing your site, including automated browsers like search engine spiders. Many of those browsers want to know what kind of content you are serving. The doctype tag allows you to specify that. By default WebGUI generates HTML 4.0 compliant content. \r\n<P><B>Favicon</B><BR>An icon that appears on Internet Explorer short cuts such as your "Favorites". To learn more about Favicon <A href="http://msdn.microsoft.com/workshop/author/dhtml/howto/shortcuticon.asp">click here</A>. \r\n<P><B>Site Icon</B><BR>An icon that appears in the URL bar of most modern browsers. It may also appear in the bookmarks of the browser. The image must be 16x16 pixels. \r\n<P><B>Add edit stamp to posts?</B><BR>Typically if a user edits a post on a discussion, a stamp is added to that post to identify who made the edit, and at what time. On some sites that information is not necessary, therefore you can turn it off here. \r\n<P><B>Filter Contributed HTML</B><BR>Especially when running a public site where anybody can post to your message boards or user submission systems, it is often a good idea to filter their content for malicious code that can harm the viewing experience of your visitors; And in some circumstances, it can even cause security problems. Use this setting to select the level of filtering you wish to apply. \r\n<P><B>Maximum Attachment Size</B><BR>The size (in kilobytes) of the maximum allowable attachment to be uploaded to your system. \r\n<P><B>Max Image Size</B><BR>If images are uploaded to your system that are bigger than the max image size, then they will be resized to the max image size. The max image size is measured in pixels and will use the size of the longest side of the image to determine if the limit has been reached. \r\n<P><B>Thumbnail Size</B><BR>When images are uploaded to your system, they will automatically have thumbnails generated at the size specified here (unless overridden on a case-by-case basis). Thumbnail size is measured in pixels. \r\n<P><B>Snippet Preview Length</B><BR>How many characters of a snippet should be displayed in the collateral management system main listing. \r\n<P><B>Text Area Rows</B><BR>Some sites wish to control the size of the forms that WebGUI generates. With this setting you can specify how many rows of characters will be displayed in textareas on the site. \r\n<P><B>Text Area Columns</B><BR>Some sites wish to control the size of the forms that WebGUI generates. With this setting you can specify how many columns of characters will be displayed in textareas on the site. \r\n<P><B>Text Box Size</B><BR>Some sites wish to control the size of the forms that WebGUI generates. With this setting you can specify how characters can be displayed at once in text boxes on the site. \r\n\r\n<BR><BR><B>Wobject Privileges</B><BR>Choose \'Yes\' to enable privileges at the Wobject level.&nbsp; By default, Wobjects are set to inherit page level privileges</P>', 1056292957,NULL);

View file

@ -277,11 +277,15 @@ sub page {
$content = WebGUI::Macro::process(WebGUI::Template::process(WebGUI::Style::get($pageEdit.WebGUI::Page::getTemplate($template)), $positions));
my $ttl;
if ($session{user}{userId} == 1) {
$ttl = $session{setting}{cachePagesVisitor};
$ttl = $session{page}{cacheTimeoutVisitor};
WebGUI::ErrorHandler::warn("setting visitor cache");
} else {
$ttl = $session{setting}{cachePages};
$ttl = $session{page}{cacheTimeout};
WebGUI::ErrorHandler::warn("setting user cache");
}
$cache->set($content, $ttl) if ($useCache);
} else {
WebGUI::ErrorHandler::warn("using cache");
}
$debug = _generateDebug();
WebGUI::Session::close();

View file

@ -32,7 +32,6 @@ our @EXPORT = qw(&www_viewPageTree &www_movePageUp &www_movePageDown
&www_editPageSave &www_pastePage &www_moveTreePageUp
&www_moveTreePageDown &www_moveTreePageLeft &www_moveTreePageRight);
#Method Added By Frank Dillon - Changes Wobject Privileges on a page
#-------------------------------------------------------------------
sub _changeWobjectPrivileges {
my($wobject,$sth);
@ -48,9 +47,7 @@ sub _changeWobjectPrivileges {
sub _recursivelyChangePrivileges {
my ($sth, $pageId);
$sth = WebGUI::SQL->read("select pageId from page where parentId=$_[0]");
#--Added By Frank Dillon - Change the Wobject Privileges on the current page
_changeWobjectPrivileges($_[0]);
#--End Changes
_changeWobjectPrivileges($_[0]);
while (($pageId) = $sth->array) {
if (WebGUI::Privilege::canEditPage($pageId)) {
WebGUI::SQL->write("update page set startDate=$session{form}{startDate},
@ -343,6 +340,22 @@ sub www_editPage {
-value=>$page{defaultMetaTags},
-uiLevel=>5
);
my @data = WebGUI::DateTime::secondsToInterval($page{cacheTimeout});
$f->getTab("properties")->interval(
-name=>"cacheTimeout",
-label=>WebGUI::International::get(895),
-intervalValue=>$data[0],
-unitsValue=>$data[1],
-uiLevel=>8
);
@data = WebGUI::DateTime::secondsToInterval($page{cacheTimeoutVisitor});
$f->getTab("properties")->interval(
-name=>"cacheTimeoutVisitor",
-label=>WebGUI::International::get(896),
-intervalValue=>$data[0],
-unitsValue=>$data[1],
-uiLevel=>8
);
%hash = WebGUI::SQL->buildHash("select styleId,name from style where name<>'Reserved' order by name");
if (WebGUI::Privilege::isInGroup(5)) {
$subtext = ' &nbsp; <a href="'.WebGUI::URL::page('op=listStyles')
@ -470,8 +483,6 @@ sub www_editPageSave {
$session{form}{menuTitle} = $session{form}{title} if ($session{form}{menuTitle} eq "");
$session{form}{urlizedTitle} = $session{form}{menuTitle} if ($session{form}{urlizedTitle} eq "");
$session{form}{urlizedTitle} = WebGUI::Page::makeUnique(WebGUI::URL::urlize($session{form}{urlizedTitle}),$session{form}{pageId});
$session{form}{startDate} = WebGUI::FormProcessor::dateTime("startDate");
$session{form}{endDate} = WebGUI::FormProcessor::dateTime("endDate");
WebGUI::SQL->write("update page set
title=".quote($session{form}{title}).",
styleId=$session{form}{styleId},
@ -480,8 +491,10 @@ sub www_editPageSave {
groupIdEdit=$session{form}{groupIdEdit},
newWindow=$session{form}{newWindow},
hideFromNavigation=$session{form}{hideFromNavigation},
startDate=$session{form}{startDate},
endDate=$session{form}{endDate},
startDate=".WebGUI::FormProcessor::dateTime("startDate").",
endDate=".WebGUI::FormProcessor::dateTime("endDate").",
cacheTimeout=".WebGUI::FormProcessor::interval("cacheTimeout").",
cacheTimeoutVisitor=".WebGUI::FormProcessor::interval("cacheTimeoutVisitor").",
metaTags=".quote($session{form}{metaTags}).",
urlizedTitle='$session{form}{urlizedTitle}',
redirectURL='$session{form}{redirectURL}',

View file

@ -109,21 +109,7 @@ sub www_editContentSettings {
$f->integer("textAreaRows",WebGUI::International::get(463),$session{setting}{textAreaRows});
$f->integer("textAreaCols",WebGUI::International::get(464),$session{setting}{textAreaCols});
$f->integer("textBoxSize",WebGUI::International::get(465),$session{setting}{textBoxSize});
my @data = WebGUI::DateTime::secondsToInterval($session{setting}{cachePages});
$f->interval(
-name=>"cachePages",
-label=>WebGUI::International::get(895),
-intervalValue=>$data[0],
-unitsValue=>$data[1]
);
@data = WebGUI::DateTime::secondsToInterval($session{setting}{cachePagesVisitor});
$f->interval(
-name=>"cachePagesVisitor",
-label=>WebGUI::International::get(896),
-intervalValue=>$data[0],
-unitsValue=>$data[1]
);
$f->yesNo("wobjectPrivileges",WebGUI::International::get(979),$session{setting}{wobjectPrivileges});
$f->yesNo("wobjectPrivileges",WebGUI::International::get(979),$session{setting}{wobjectPrivileges});
$f->submit;
$output .= $f->print;
return _submenu($output);

View file

@ -120,6 +120,28 @@ sub countTemplatePositions {
#-------------------------------------------------------------------
=head2 deCache ( [ pageId ] )
Deletes the cached version of a specified page.
=over
=item pageId
The id of the page to decache. Defaults to the current page id.
=back
=cut
sub deCache {
my $cache = WebGUI::Cache->new;
my $pageId = $_[0] || $session{page}{pageId};
$cache->deleteByRegex("m/^page_".$pageId."_\\d+\$/");
}
#-------------------------------------------------------------------
=head2 drawTemplate ( templateId )
Returns an HTML string containing a small representation of the page template.