From 4030deb2658e1aacec5f85ac98f4a2871d75044a Mon Sep 17 00:00:00 2001 From: MichaelDaum Date: Fri, 9 Sep 2016 13:55:14 +0200 Subject: [PATCH] Item14185: improved cache maintenance - add a rest handler to purge the cache occasionally - update cache files when source css/js is newer - do not remove type info on script, link and style elems - do not optimize javascript by default, PatternSkin doesn't cope well with it yet --- .gitignore | 14 ++--- data/System/PageOptimizerPlugin.txt | 1 + lib/Foswiki/Plugins/PageOptimizerPlugin.pm | 24 ++++---- .../Plugins/PageOptimizerPlugin/Config.spec | 14 ++++- .../Plugins/PageOptimizerPlugin/Core.pm | 56 ++++++++++++++++--- 5 files changed, 79 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index 1659fc0..37c1683 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ *.swp -PageOptimizerPlugin.md5 -PageOptimizerPlugin.sha1 -PageOptimizerPlugin.tgz -PageOptimizerPlugin.txt -PageOptimizerPlugin.zip -PageOptimizerPlugin_installer -PageOptimizerPlugin_installer.pl +/PageOptimizerPlugin.md5 +/PageOptimizerPlugin.sha1 +/PageOptimizerPlugin.tgz +/PageOptimizerPlugin.txt +/PageOptimizerPlugin.zip +/PageOptimizerPlugin_installer +/PageOptimizerPlugin_installer.pl diff --git a/data/System/PageOptimizerPlugin.txt b/data/System/PageOptimizerPlugin.txt index c67cc49..52a498e 100644 --- a/data/System/PageOptimizerPlugin.txt +++ b/data/System/PageOptimizerPlugin.txt @@ -69,6 +69,7 @@ the =refresh= url parameter: %$DEPENDENCIES% ---++ Change History +| 09 Sep 2016: | improved cache handling, i.e. added a rest handler to purge the cache occasionally | | 13 Jun 2016: | fixed compatibility with AngularPlugin/AngularSkin; performance improvements | | 23 Feb 2015: | remove some bogus non-macros if left over, such as REVISIONS, REVTITLE, REVARG, QUERYPARAMSTRING | | 04 Apr 2014: | flag rest handlers that don't require authentication | diff --git a/lib/Foswiki/Plugins/PageOptimizerPlugin.pm b/lib/Foswiki/Plugins/PageOptimizerPlugin.pm index 4e0c410..34da8fe 100644 --- a/lib/Foswiki/Plugins/PageOptimizerPlugin.pm +++ b/lib/Foswiki/Plugins/PageOptimizerPlugin.pm @@ -24,8 +24,8 @@ use Digest::MD5 (); use URI (); use Compress::Zlib (); -our $VERSION = '2.00'; -our $RELEASE = '10 Jun 2016'; +our $VERSION = '2.10'; +our $RELEASE = '09 Sep 2016'; our $SHORTDESCRIPTION = 'Optimize html markup, as well as js and css'; our $NO_PREFS_IN_TOPIC = 1; our $core; @@ -42,6 +42,12 @@ sub initPlugin { http_allow => 'GET', ); + Foswiki::Func::registerRESTHandler('purgeCache', sub { return getCore()->purgeCache(@_); }, + authenticate => 0, + validate => 0, + http_allow => 'GET,POST', + ); + return 1; } @@ -69,6 +75,9 @@ sub getStats { sub finishPlugin { $core->finish if defined $core; $stats->finish if defined $stats; + + undef $core; + undef $stats; } ############################################################################### @@ -101,10 +110,6 @@ sub completePageHandler { $text =~ s/\%\{(]*>)\}%\s*/$1/g; $text =~ s/\s*%\{(<\/pre>)\}\%/$1/g; - $text =~ s/