Placeholders cache and invalidation and plugins?

Showing 1-2 of 2 messages
Placeholders cache and invalidation and plugins? galgal 9/20/12 2:46 PM
Is there any way, to detect, by signals, that plugin has been changed, then get plugin placeholder id and invalidate cached content, based on placeholder id?
On some pages I have more than 200 queries because of many plugins used in placeholders. My strategy is to cache that by {% cache %} and as a key i want to use: "cache_placeholder id". But I need to detect plugin changed to invalidate it.

Thanks in advance.
Re: Placeholders cache and invalidation and plugins? Benjamin Wohlwend 9/21/12 12:34 AM
Hi,

On Thu, Sep 20, 2012 at 11:46 PM, robos85 <weglare...@gmail.com> wrote:
> Is there any way, to detect, by signals, that plugin has been changed, then
> get plugin placeholder id and invalidate cached content, based on
> placeholder id?

You could listen on the post_save signal of CMSPlugin:

models.signals.post_save.connect(invalidate_plugin_cache, sender=CMSPlugin)

your handler receives a CMSPlugin instance with a reference to the
placeholder. Note that this doesn't work if the plugin displays data
that isn't stored in the plugin instance itself, e.g. a list of newest
blog entries.

> On some pages I have more than 200 queries because of many plugins used in
> placeholders. My strategy is to cache that by {% cache %} and as a key i
> want to use: "cache_placeholder id". But I need to detect plugin changed to
> invalidate it.

Did you try the newly released django CMS 2.3.2? We reduced queries
generated by plugins and placeholders significantly since 2.3.0, it
might solve your problems without using brittle cache mechanisms.

Kind regards,
Benjamin