Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A Simple Cache plugin
#1
Hi-

I just uploaded a very basic page cache plugin:

http://get-simple.info/extend/plugin/sim...plugin/56/

Page content is cached.

The cache is flushed when any page is saved.

There is no time expire on the cache files in this version.

I've tried it on my site and it works quite nicely. Note that the use of any page cache will prevent plugins that generate dynamic content from functioning properly.

Thoughts?

-Rob A>
Reply
#2
In a quick test, I've found that non-existent pages ("Oops! Not found") also get cached (one cache file for each different URL).

BTW there already was another similar plugin, nexflo's GS_cache:
http://get-simple.info/forum/topic/608/gt-cache/
You may find some ideas for yours in that thread.
Reply
#3
Carlos Wrote:BTW there already was another similar plugin, nexflo's GS_cache:
http://get-simple.info/forum/topic/608/gt-cache/
You may find some ideas for yours in that thread.

Grrr.

I searched both the forums and the Extend site and found no page cache.

Oh well.

I took some ideas from that code, played with setting up a back end page to delete individual pages or flush the entire cache. Still working on it though. (latest version is in Extend)

Two questions -
Is there a plugin configuration framework in place or does each plugin handle its own configuration stuff?
Can a plugin register in more than one backend location?

I wanted to have a config page (ttl, pages to exclude from caching) as well as a cached pages management page, for logical separation. If not I guess it can all be in one and I'll move it to the plugin page.

-Rob A>
Reply
#4
Update to 0.3.

I rejiggered things a bit so cache files are stored with MD5 hashed filenames.

The backend UI looks like the attached, showing the pages and their cache status, using the GS classes for a consistent look. Still need to get the parent/child logic in so it displays same as the View All Pages page. In an ideal would that UI would be extendable and I could have just added a column in there, oh well.

I plan to add another column of checkboxes so you can control whether each page is cached (the code is there right now but the only page islug in the array is '404' so the page not found page is not being cached). I was hoping to get an answer on storing plugin configuration information first, rather than voyaging out on my own.

I also was going to add a configuration parameter of the time to expire a cached page as a user setting.

-Rob A>
Reply
#5
Updated to version 0.4 - I'm almost ready to call this a 1.0

The SimpleCache plugin now has:
  • per page cache disabling
  • an option disable caching completely
  • a stale time setting for cache files
  • a prettier UI

Attached is a screen grab of the backend.

I'd love:
  • additional people to try this out. (I see a significant speed improvement on my site)
  • someone else to look through the code. I'm a bit of a duffer Smile

-Rob A>
Reply
#6
Those new expire and page exclude options are great, very nice plugin!
Reply
#7
yes, great plugin
Reply
#8
This does look great Rob!
- Chris
Thanks for using GetSimple! - Download

Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Reply
#9
Very nice plugin, but it doesn't cache pages from the second page of list in admin panel->pages.
Or i may say in other way - your plugin cache only 15 pages.
Reply
#10
kirilldmt Wrote:Very nice plugin, but it doesn't cache pages from the second page of list in admin panel->pages.
Or i may say in other way - your plugin cache only 15 pages.

Can someone else test that? There is nothing that should prevent more than 15 pages from being cached...

-Rob A>
Reply
#11
In SimpleCache status page I get a list of a maximum of 14 pages. :-?

However, all pages seem to be cached ok (when browsed, of course).

(Quick test done with 30 pages.)
Reply
#12
Ok, found it. Only first 14 pages are shown when javascript enabled. Some conflict with page editor styles.
Fix:

Edit simplecache.php, line 336:
Code:
echo '<table class="edittable highlight paginate">';
change to:
Code:
echo '<table class="edittable highlight">';
Reply
#13
Carlos Wrote:Ok, found it. Only first 14 pages are shown when javascript enabled. Some conflict with page editor styles.
Fix:

Edit simplecache.php, line 336:
Code:
echo '<table class="edittable highlight paginate">';
change to:
Code:
echo '<table class="edittable highlight">';

Thanks. That's what I get for borrowing styles without digging deeper. Would pagination in the backend make sense?

Alternately, a hook in the main pages page would let me inject new columns in to the existing table without reconstructing everything.

Rob A>
Reply
#14
Another small update - now at 0.5
  • Fixed the pagination (Thanks Carlos!).
  • Changed the classes so disabled message is displayed as an error
  • Made the delete all cahed pages button disabled rather than missing when there are no cached pages (better UI design)

-Rob A>
Reply
#15
Another tiny update - Borrowed the page sorting code from the core so the cache will display in the same order.

-Rob A>
Reply
#16
I want to make it easier to work with other plugins/dynamic content generation.

The easiest way to do this to to come up with a comment, say:
Code:
<!-- SimpleCache NO -->

That a plugin can emit in the page, and then my plugin would ignore that page and not cache it.

I tried it on my dev server with a test plugin and it seems to work well, and is easier than a user having to go into the cache settings and disable the cache for that page.

Thoughts?

-Rob A>
Reply
#17
I've updated this plugin in extend:

- code cleanup
- improved XML config file handling
- proper use of quotes
- updated to GS coding style
- updated backend to use GS3 classes

-Rob A>
Reply
#18
One more small update
- bugfix for proper sorting of pages nested more than one deep
- updated list display to use the same style as the page management page.

-Rob A>
Reply
#19
Suggestion: only serve cached pages to users who are not logged in (or make this optional)

Another one: What about moving SimpleCache Settings to the top of the settings page, before the SimpleCache Status list? (or at least put an anchor link there)
Reply
#20
Carlos Wrote:Suggestion: only serve cached pages to users who are not logged in (or make this optional)

Another one: What about moving SimpleCache Settings to the top of the settings page, before the SimpleCache Status list? (or at least put an anchor link there)

Good idea on the organization - I've changed it in my core and will update extend that way at the next big change.

Regarding the other, I'm still developing for 3.0 as it is the current official release and the cookie magic to determine if a use is logged in is broken, so there is no easy way to do this (from the front end pages) without changing the core code.

-Rob A>
Reply
#21
RobA Wrote:Regarding the other, I'm still developing for 3.0 as it is the current official release and the cookie magic to determine if a use is logged in is broken, so there is no easy way to do this (from the front end pages) without changing the core code.

A workaround for the cookie problem in 3.0 can be found here.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#22
mvlcek Wrote:
RobA Wrote:Regarding the other, I'm still developing for 3.0 as it is the current official release and the cookie magic to determine if a use is logged in is broken, so there is no easy way to do this (from the front end pages) without changing the core code.

A workaround for the cookie problem in 3.0 can be found here.

As far as I can tell, that only works in the back end.


-Rob A>
Reply
#23
RobA Wrote:
mvlcek Wrote:A workaround for the cookie problem in 3.0 can be found here.

As far as I can tell, that only works in the back end.

It works when calling php-files in the plugins folder.
It works when calling this test file in the root of the installation:
Code:
<?php
  include('gsconfig.php');
  $admin = defined('GSADMIN') ? GSADMIN : 'admin';
  include("${admin}/inc/common.php");
  $loggedin = cookie_check();
  if (!$loggedin) die("Not logged in!");
  echo "LOGGED IN!";
So it should work in the frontend, too.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#24
mvlcek Wrote:
RobA Wrote:
mvlcek Wrote:A workaround for the cookie problem in 3.0 can be found here.

As far as I can tell, that only works in the back end.

It works when calling php-files in the plugins folder.
It works when calling this test file in the root of the installation:
Code:
<?php
  include('gsconfig.php');
  $admin = defined('GSADMIN') ? GSADMIN : 'admin';
  include("${admin}/inc/common.php");
  $loggedin = cookie_check();
  if (!$loggedin) die("Not logged in!");
  echo "LOGGED IN!";
So it should work in the frontend, too.

It doesn't.

common.php has the code:
Code:
/**
* $base is if the site is being viewed from the front-end
*/
if(!isset($base)) {
    include_once(GSADMININCPATH.'cookie_functions.php');
} else {
    include_once(GSADMININCPATH.'theme_functions.php');
}

so cookie_functions.php doesn't get included when viewing a page in the front end. Sure it works in stand alone files because of the $base check.

-Rob A>
Reply
#25
RobA Wrote:so cookie_functions.php doesn't get included when viewing a page in the front end. Sure it works in stand alone files because of the $base check.

If this is the only problem, you can include the cookie_functions.php yourself (or copy the cookie_check function).
But it really depends on how important the functionality is to you and the users of your plugin ;-)
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply




Users browsing this thread: 2 Guest(s)