Jun
13

Staticize Reloaded

Filed under: Uncategorized | Tags: | June 13th, 2004
Post

The caching plugin I pointed to the other day was very well-executed but it didn’t meet my needs for several reasons, mainly that it cached every bit of output, which wouldn’t be appropiate for things like my random photo. (Or my non-rotating photo formerly known as the random photo in the header. It’s on break right now.) My site is a pretty neat system of PHP includes, and I want to preserve that because it makes my life easy and doesn’t slow anything down any perceptable amount.

So I took the Staticize plugin and added support for dynamic non-cached sections, cleaned up the code a bit, fixed a weird problem where it would just show a blank page if it couldn’t write the file, fixed the problem with edit links and the comment form, and made it fit with the WordPress code a little smoother. Full instructions are included with the plugin, but to install just make sure your wp-content folder is writable (you may have already done that when setting up WP) and activate the plugin, and it will start working immediately.

I have a couple more improvements in mind for it already, but it’s fully functional and I’m running it right now.

Download Staticize Reloaded 2.0.

38 Responses

MaThIbUs | June 13th, 2004 @ 6:17 am

Sounds great, I will try this out!

Scott | June 13th, 2004 @ 7:32 am

Cool. I personally prefer plugins to includes, so I added a line to your code to allow me to exclude a function from the case as well as a include:

$store = preg_replace('|<!--fclude (.*?)-->(.*?)<!--/fclude-->|s', '<?php $1 ;?>', $buffer);

Then in my template I use the syntax:

<!--fclude heldomatic() -->
<?php heldomatic(); ?>
<!--/fclude-->

Seems to work.

Matt | June 13th, 2004 @ 12:18 pm

Well I suppose it could be easily modified to allow any PHP code, but because it’s included from inside a function every variable that was used would have to be explicitly global.

Pingback: ryanschwartz.net

Kevin Francis | June 14th, 2004 @ 12:23 am

This sounds really nice. I’ll have to implement it on my site. I find that WordPress is quite easy on my machines load average though.

Mojo Jojo | June 14th, 2004 @ 11:55 am

Should I should exclude the following items:
- Related posts plugin
- Google AdSense

Matt | June 14th, 2004 @ 1:44 pm

Mojo, those should be fine if cached.

Ryan Schwartz | June 14th, 2004 @ 9:28 pm

heh - make that <!– Dynamic Page Served (once) in 0.209 seconds –>
<!– Static Page Served in 0.003 seconds –> (php in comments = blank space…)

dowingba | June 14th, 2004 @ 11:49 pm

Still invalidates my pages when I use it. Is there something in the head section that I should be implementing with php includes?

Matt | June 15th, 2004 @ 10:05 pm

Dowingba, how does it invalidate your pages?

dowingba | June 15th, 2004 @ 11:56 pm

As far as I can tell, all the trackback rdf info shows up as invalid for some reason when I use the plugin (and the original version of the plugin). I deactivate the plugin and all is well. I’m assuming there’s some snippet of code in the head somewhere that isn’t being cached/served and the rdf stuff depends on it somehow.

supernoob boob | June 17th, 2004 @ 4:37 am

This is probably a php/fopen thang, but I noticed that if a parent directory is not world readable (even if +x), the script fails and says that it can’t create the temp files (although it creates the wp_content/cache dir just fine).

I am far from a php guru, but thought i’d mention that I had to chmod o+r all the way down my dir tree in order for this plugin to work (all previous plugins seemed to work okay before *shrug*).

Monkey830 | June 22nd, 2004 @ 12:06 pm

Doesn’t this result in the cache directory becoming full of files that aren’t used (older versions of pages)?

Alex | June 22nd, 2004 @ 12:51 pm

Does not play well with AK’s ‘New Since Last Visit’ plugin.

Tao of Dowingba » Reloaded | June 23rd, 2004 @ 2:13 am

[...] [...]

supernoob | June 24th, 2004 @ 3:13 pm

Hrm. I’m running into a problem with the required include file (for blogrolls) being cached as well. The output isn’t updated unless a new comment or entry is added in WP and it should be dynamic.

In my index.php file I have a require in there pointing to my blogroll:

< ?php require 'includes/blogroll.php'; ?>

blogroll.php contents are simply:

< ?php wp_get_links(1); ?>

Any ideas if I missed something or am doing something wrong? If I shut off the caching plugin, it updates properly.

Thanks!

supernoob | June 24th, 2004 @ 3:16 pm

Hrm. Code seems to have been stripped out of the above comment when surrounded by code tags. I’ll try again:

index.php:
<?php require ‘includes/blogroll.php’; ?>

blogroll.php:
<?php wp_get_links(1); ?>

Eli Sarver | June 24th, 2004 @ 6:47 pm

You might want to do something about caching pages before they are gzipped. I think I’ll turn on mod_compress to get around this issue.

中文WordPress » WP网页静态化 | July 15th, 2004 @ 5:30 pm

[...] Mikeluæ"°çš„æ"‡ç« ä¸­æŽ¨èäº†ä¸¤ç§ï¼'一种是Matt写的staticize的工具ï¼'另一个是jens写的Prerendering工具 [...]

Daniel | August 24th, 2004 @ 12:44 am

This is excellent, I must say. The benefits of static pages without the pain of republishing.

One issue however: it doesn’t appear to rebuild pages when a trackback comes in. I’ve tried this on a couple of WP installations, and it seems to be consistent in this.

Sean_Long | August 30th, 2004 @ 10:24 pm

I have a problem when using Staticize Reloaded plugin provided with the 2004.08.30 nightly build of WordPress. WordPress is installed into a different directory using this method: different address.

The “different address” hack works without the plugin activated. When activated, I have this error message:

Warning: main(/home/seanlong/www/wp//wp/wp-header.php): failed to open stream: No such file or directory in /home/seanlong/www/index.php on line 4

Warning: main(): Failed opening ‘/home/seanlong/www/wp//wp/wp-header.php’ for inclusion (include_path=’.:/usr/local/lib/php’) in /home/seanlong/www/index.php on line 4

Any ideas?

Michael | September 9th, 2004 @ 11:09 pm

The exclude syntax doesn’t work with BBClone Stats. Tested on three blogs. Nonetheless still very cool.

Paul Hoch | September 30th, 2004 @ 7:02 pm

After installing it, everything seems cool, although my RSS feed doesn’t appear to refresh. Is there a workaround? I’ve checked in two different readers (Firefox live bookmars, and RSS Bandit). Since I activated the plugin neither has received anything new.

mskallas | December 2nd, 2004 @ 1:20 pm

Getting:

Parse error: parse error in /web/script/skallas/nerdfilter.com/wp-content/cache/2d1279da46f6ac2c2771aecbcdd1ec0e.php on line 1

ricardo galli | December 24th, 2004 @ 7:13 pm

I found an important concurrency bug: if more than a client access to the same page, the same content could be appended several times to the same cache file.

It’s repeatable by using Apache Benchmark (ab).

Matt | December 25th, 2004 @ 12:22 pm

Ricardo, I’ll look into that.

Rian | May 26th, 2005 @ 6:08 pm

This plugin has successfully turned my WP pages into gibberish 50% of the time. In Opera and Firefox both. Sometimes refreshing it fixes it, and sometimes it doesn’t.

Anyone else have this problem?

Matt | May 27th, 2005 @ 8:33 am

That’s usually a problem when you don’t turn gzip off like the instructions say.

Brandon Harper | July 6th, 2005 @ 9:15 pm

This plugin has been updated here:

http://mnm.uib.es/gallir/wp-cache-2/

If you’ve had problems with it (my RSS was breaking for instance), you might want to try the latest version.

Pingback: Qbic

Joseph | December 15th, 2005 @ 9:55 pm

No thanks, i think i’ll stay away from something that can wreak havoc and bust your set up just to save a few miliseconds of time that you can do easily by just trimming the fat off the site. Laziness can make more trouble than using a little effort.

Still, hope you guys finally work it out.

Share your thoughts