Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A Simple Cache plugin
#27
Based on a PM about performance, I looked into adding Mod Rewrite caching to this plugin.

Attached is a first attempt at that if someone wants to try it.

I'm using it on my test site http://testbed.cartocopia.com/ and it seems successful.


This version adds a new option titled "Create symlinks in the home directory to allow Mod Rewrite caching." (wordy, I know).

If this option is selected, when a cache file is created in the data/other/simplecache/ directory the plugin also creates a symlink in the GS root directory named slug.html (for eample, the default page, having the slug "index" will generate a symlink named "index.html" pointed to the cache file.

To leverage this you need to:
1) set a custom permalink structure: %slug%.html
2) change your .htaccess rewrite rules to use this structure, and add the check option. Below is mine:
Code:
AddDefaultCharset UTF-8
RewriteEngine on

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#added the -l check for the cache symlinks
RewriteCond %{REQUEST_FILENAME} !-l
#for caching using custom permalink %slug%.html
RewriteRule ([A-Za-z0-9_-]+)[.]html index.php?id=$1 [QSA,L]

So what this does, is.. if a request comes in for a page like http://testbed.cartocopia.com/disqus-test-page.html the web server rules will additionally check to see if there is no symlink with that name, and if not will throw it off to index.php to generate the page (and the cache file). If the cache file (and the link to it) already exist it just serves up the cached file directly via the symlink.

This should be much faster as the php process does not even get invoked.

The only "drawback" is that you cant regenerate cached files based on time accessing them this way, as php is not being called and Mod Rewrite can't do a check for file date. The only way to regenerate them the normal simplecache way is by accessing them via the index.php?id=slug URL or just deleting them from the back end maintenance page.

I'm sure more complicated adresses could be created, but that would require code changes to the plugin as it is hard-coded to save the files as slug.html

Any thoughts on the usefulness/value of this? Not sure if I should update the version in extend...

-Rob A>
Reply


Messages In This Thread
A Simple Cache plugin - by RobA - 2010-11-11, 04:43:49
RE: A Simple Cache plugin - by Arugula - 2015-05-21, 11:29:59
RE: A Simple Cache plugin - by shawn_a - 2015-05-22, 09:51:23
RE: A Simple Cache plugin - by Carlos - 2015-05-22, 15:58:34
RE: A Simple Cache plugin - by RobA - 2015-05-29, 22:58:26
RE: A Simple Cache plugin - by zekoolweb - 2020-09-26, 20:23:18
RE: A Simple Cache plugin - by Felix - 2020-09-27, 01:31:40
RE: A Simple Cache plugin - by zekoolweb - 2020-09-27, 02:54:23
RE: A Simple Cache plugin - by Felix - 2020-09-27, 04:21:03
RE: A Simple Cache plugin - by zekoolweb - 2020-09-28, 08:47:12
RE: A Simple Cache plugin - by johnywhy - 2022-12-30, 18:01:34
A Simple Cache plugin - by Carlos - 2010-11-11, 07:00:42
A Simple Cache plugin - by RobA - 2010-11-11, 10:44:02
A Simple Cache plugin - by RobA - 2010-11-12, 01:27:58
A Simple Cache plugin - by RobA - 2010-11-13, 05:28:42
A Simple Cache plugin - by Carlos - 2010-11-13, 07:29:33
A Simple Cache plugin - by Oleg06 - 2010-11-13, 20:10:42
A Simple Cache plugin - by ccagle8 - 2010-11-13, 23:33:07
A Simple Cache plugin - by kirilldmt - 2010-11-14, 06:48:56
A Simple Cache plugin - by RobA - 2010-11-14, 07:24:00
A Simple Cache plugin - by Carlos - 2010-11-14, 08:44:34
A Simple Cache plugin - by Carlos - 2010-11-14, 18:38:15
A Simple Cache plugin - by RobA - 2010-11-14, 23:41:01
A Simple Cache plugin - by RobA - 2010-11-16, 06:34:09
A Simple Cache plugin - by RobA - 2010-12-01, 02:38:14
A Simple Cache plugin - by RobA - 2010-12-15, 06:38:07
A Simple Cache plugin - by RobA - 2011-04-21, 02:43:49
A Simple Cache plugin - by RobA - 2011-05-27, 04:43:49
A Simple Cache plugin - by Carlos - 2011-06-23, 19:24:09
A Simple Cache plugin - by RobA - 2011-06-24, 02:39:26
A Simple Cache plugin - by mvlcek - 2011-06-24, 02:56:12
A Simple Cache plugin - by RobA - 2011-06-24, 23:47:32
A Simple Cache plugin - by mvlcek - 2011-06-25, 00:59:44
A Simple Cache plugin - by RobA - 2011-06-25, 01:15:32
A Simple Cache plugin - by mvlcek - 2011-06-25, 01:22:54
A Simple Cache plugin - by RobA - 2011-06-25, 05:45:11
A Simple Cache plugin - by RobA - 2011-07-30, 02:16:12
A Simple Cache plugin - by flam316 - 2011-08-02, 15:07:31
A Simple Cache plugin - by RobA - 2011-08-02, 21:16:18
A Simple Cache plugin - by RobA - 2011-08-02, 23:12:08
A Simple Cache plugin - by Yurbasik - 2011-09-22, 22:56:53
A Simple Cache plugin - by doice - 2012-03-13, 05:00:11
A Simple Cache plugin - by RobA - 2012-03-14, 04:49:06
A Simple Cache plugin - by doice - 2012-03-15, 02:34:41
A Simple Cache plugin - by Ed at ISI - 2012-06-22, 09:30:16



Users browsing this thread: 1 Guest(s)