Discussion:
post_content_filtered
d***@semiologic.com
2005-04-19 22:02:40 UTC
Permalink
I noticed this 'post_content_filtered' column in the posts table. It doesn't
appear to be used anywhere in wp. Is this a remnant of a past version of wp,
something a plugin installed on my site, something else...?

--
Denis
http://www.semiologic.com

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
Matt Mullenweg
2005-04-19 22:05:28 UTC
Permalink
Post by d***@semiologic.com
I noticed this 'post_content_filtered' column in the posts table. It doesn't
appear to be used anywhere in wp. Is this a remnant of a past version of wp,
something a plugin installed on my site, something else...?
It can be used by plugins for caching expensive post content
transformations.
--
Matt Mullenweg
http://photomatt.net | http://wordpress.org
http://pingomatic.com | http://cnet.com
d***@semiologic.com
2005-04-19 22:32:19 UTC
Permalink
Sounds like a good idea indeed. I was just surprised to find no hook anywhere to
call it in the WordPress code. At the moment, the only occurence of it is in the
install script.

I would have imagined finding something somewhere like:

if ( $post->post_content_filtered )
// bypass post_content filters

and like:

apply_filters( wherever_relevant, update_post_content_filtered )

at other places. But leave as is, I presume, as there is room to cache things
differently from a site to another.

Speaking of which: If I make a plugin to fill the field every so often on a
semi-static basis rather than on a per-modification basis, is there a way to I
disable the apply_filters call on the_content altogether?

D.
Post by d***@semiologic.com
Post by d***@semiologic.com
I noticed this 'post_content_filtered' column in the posts table. It
doesn't
Post by d***@semiologic.com
appear to be used anywhere in wp. Is this a remnant of a past version of
wp,
Post by d***@semiologic.com
something a plugin installed on my site, something else...?
It can be used by plugins for caching expensive post content
transformations.
--
Matt Mullenweg
http://photomatt.net | http://wordpress.org
http://pingomatic.com | http://cnet.com
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
Mark Jaquith
2005-04-19 23:05:58 UTC
Permalink
Post by d***@semiologic.com
I noticed this 'post_content_filtered' column in the posts table. It doesn't
appear to be used anywhere in wp. Is this a remnant of a past version of wp,
something a plugin installed on my site, something else...?
I have used it to apply all "the_content" filters to the content and
then store the filtered output. This is what TextPattern does (or did,
last time I checked). Some filters are VERY expensive to run realtime.
Textile 2 in PHP is a monster... so much so that your main page or
monthly archives may refuse to load on some servers. So what you can do
is have the Textile 2 filter run when you edit or publish an entry, and
then you'll just directly output the processed content.

I did some work on a plugin that someone wrote last year that did this:

http://persson.cx/archives/2004/06/15/prerendering-in-wordpress/

If you're running Textile 2 or another expensive text-processing engine,
it could make your pages load a lost faster.

- Mark Jaquith
d***@semiologic.com
2005-04-20 00:40:02 UTC
Permalink
Post by Mark Jaquith
If you're running Textile 2 or another expensive text-processing engine,
it could make your pages load a lost faster.
Actually, it's a bit more complex:

I've Markdown running and indeed it is a hogger. But I've also a smart link
plugin in beta test on my site.

http://www.semiologic.com/projects/smart-link/

It is even more a hogger than Markdown. :P And I expect two more plugins in my
pipe will make things even worse.

I suspect your plugin will introduce more problems than it solves in my case. I
would need to use the_prerendered_content() instead of the_content() in my
theme, and assume other plugin users will do the same -- I suspect this is too
complex for most users.

Thus, I'd be curious to know if someone has some code available that traverses
the the_content filter, adds a caching trigger at the end of it, and triggers
the caching during shutdown. If not, I guess I'm in for another plugin...

--
Denis
http://www.semiologic.com

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
Mark Jaquith
2005-04-20 01:18:58 UTC
Permalink
Post by d***@semiologic.com
I suspect your plugin will introduce more problems than it solves in my case. I
would need to use the_prerendered_content() instead of the_content() in my
theme, and assume other plugin users will do the same -- I suspect this is too
complex for most users.
Thus, I'd be curious to know if someone has some code available that traverses
the the_content filter, adds a caching trigger at the end of it, and triggers
the caching during shutdown. If not, I guess I'm in for another plugin...
If you call the_prerendered_content() on a post with no cached content,
it will apply the filters right then and cache the content live. The
performance is identical to running the filters live, with the
difference being that subsequent loads would use the cached content,
which is much faster. Having to modify the theme is a necessary evil,
at least the way I saw it. I've tried plugins that run as a filter on X
and then try to modify filters on X live, and it really doesn't work so
well.

- Mark Jaquith
Robert Deaton
2005-04-20 01:24:43 UTC
Permalink
I'd be all for having the options in the admin on whether or not to cache,
and a button to clear the cache (and a hook for plugins to do so if they're
applying other filters). The default set of the_content and such could load
the cached content if the option is enabled in the admin.
Post by d***@semiologic.com
Post by d***@semiologic.com
I suspect your plugin will introduce more problems than it solves in my
case. I
Post by d***@semiologic.com
would need to use the_prerendered_content() instead of the_content() in
my
Post by d***@semiologic.com
theme, and assume other plugin users will do the same -- I suspect this
is too
Post by d***@semiologic.com
complex for most users.
Thus, I'd be curious to know if someone has some code available that
traverses
Post by d***@semiologic.com
the the_content filter, adds a caching trigger at the end of it, and
triggers
Post by d***@semiologic.com
the caching during shutdown. If not, I guess I'm in for another plugin...
If you call the_prerendered_content() on a post with no cached content,
it will apply the filters right then and cache the content live. The
performance is identical to running the filters live, with the
difference being that subsequent loads would use the cached content,
which is much faster. Having to modify the theme is a necessary evil,
at least the way I saw it. I've tried plugins that run as a filter on X
and then try to modify filters on X live, and it really doesn't work so
well.
- Mark Jaquith
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
--
--Robert Deaton
http://somethingunpredictable.com
d***@semiologic.com
2005-04-20 01:46:57 UTC
Permalink
Post by Mark Jaquith
which is much faster. Having to modify the theme is a necessary evil,
at least the way I saw it. I've tried plugins that run as a filter on X
and then try to modify filters on X live, and it really doesn't work so
well.
I was just discussing the following workflow with Jérôme Lavigné:


on display post: -- sem_smart_cache_display()

- plugin hook at priority 1 on the_content detects if cache needs an update
(e.g. older than 24h)

if no cache update is necessary:

- make a copy of the_content filter array, traverse the_content filter array,
remove all filters, add a sem_no_smart_cache filter at the end of the array;
return post_content_filtered
- at sem_no_smart_cache(), restore the the_content filter array for use by the
next post; return as normal

if cache update is necessary:

- make a copy of the_content filter array, traverse the_content filter array and
add a sem_do_smart_cache filter at the end of the array; return post_content
- at sem_do_smart_cache(), do to_smart_cache[$ID]=$post_content and restore the
the_content filter array for use by the next post; return as normal


on edit/publish: -- sem_smart_cache_save()

- apply_filters to the content and do to_smart_cache[$ID]=$post_content, but be
wary
of disabling the priority 1 filter first to avoid strange behaviors


on shutdown: -- sem_smart_cache_shutdown()

- at 'shutdown' hook, we can safely do the sql inserts without bothering the
user with delays


this workflow requires no particular action by the user -- as opposed to
replacing the the_content() call in a template. the only requirement is some
rigor, a time stamp in the post metas, and perhaps an option (number of hours
between each update).


for comments, straightforward caching with no refresh is obviously the right
thing to do.


One downside: There is potential for huge bugs if another plugin is modifying
the the_content loop as well. I'll live with it risk. ;)

--
Denis
http://www.semiologic.com


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

Loading...